- Difficulty: Medium
- Tags: LeetCode, Medium, Linked List, Math, leetcode-369, O(n), O(1), 🔒, Two Pointers
Problem
Given a non-negative integer represented as a linked list of digits, plus one to the integer.
The digits are stored such that the most significant digit is at the head
of the list.
Â
Example 1:
Input: head = [1,2,3] Output: [1,2,4]
Example 2:
Input: head = [0] Output: [1]
Â
Constraints:
- The number of nodes in the linked list is in the range
[1, 100]
. 0 <= Node.val <= 9
- The number represented by the linked list does not contain leading zeros except for the zero itself.Â