0369. Plus One Linked List
https://leetcode.com/problems/plus-one-linked-list
Description
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:
Example 2:
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.
ac1: recursive
ac2: iterative
This one is really smart, but it's not a general solution, only suitable for this one.
Last updated