1234 is represented as (1 -> 2 -> 3 -> 4) and adding 1 to it should change it to (1 -> 2 -> 3 -> 5).
The input Linked list does not have any trailing zeros.
The first line contains an integer 'T' which denotes the number of test cases or queries to be run.
The first line of each test case contains ‘N’ space-separated integers denoting the nodes of the Linked List. Here, ‘-1’ will be present at the end of each test case denoting the termination of the linked list.
For each case, we need to return the updated linked list where each node will be separated by a space.
The output of each test case will be printed in a separate line.
You do not need to input or print anything, and it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 10000
0 <= |nodeValue| <= 9
Where ‘N’ denotes the size of the linked list.
Time Limit: 1 sec
Here, the number is represented from left to right but while adding one, we need to travel the number from right to left. Firstly, we need to reverse the list, then we will add 1 to the first digit and maintain a variable carry which will to added to the second digit if required and this process goes on. Finally, once our addition is done, we can reverse the list again and return the head.
Equal Arrays
Ninja And The Strictly Increasing Array
Maximize
Delete Nodes On Regular Intervals
Add One To Linked List