Add 1 to a number represented as linked list
Submissions: 7074   Accuracy:

54.55%

  Difficulty: Easy   Marks: 2

A number (n) is represented in Linked List such that each digit corresponds to a node in linked list. Add 1 to it.

Input:
You have to complete the method which takes one argument: the head of the linked list. You should not read any input from stdin/console.. There are multiple test cases. For each test case, this method will be called individually

Output:
Your function should return pointer to head of the modified list.

Constraints:
1 <=T<= 50
1 <=n<= 10000

Example:

Input:
4
456
123
999
1879

Output:
457 
124 
1000 
1880

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: vaibhav2992


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.