Easy Accuracy: 51.33% Submissions: 68964 Points: 2

A number N is represented in Linked List such that each digit corresponds to a node in linked list. You need to add 1 to it.

Example 1:

Input:
Output: 457


Example 2:

Input:
Output: 124 

Note: The head represents the left-most digit of the number.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).

Constraints:
1 <= N <= 101000

We are replacing the old Disqus forum with the new Discussions section given below.