

Input: Initial Linked List: 1 -> 5 -> 2
Output: Modified Linked List: 1 -> 5 -> 3
Explanation: Initially the number is 152. After incrementing it by 1, the number becomes 153.
The first line contains an integer 'n', the length of the number / the length of the linked list.
The second line contains 'n' space separated integers denoting the digits of the number / the nodes of the linked list.
Print space - separated integers denoting the nodes of the output linked list.
You do not need to print anything. You're given the head of the linked list, return the head of the modified list.
In this approach, we will use recursion to add 1 to the linked list. We can recursively reach the last node, add 1 to it and forward the carry to the previous node.
This solution does not require reversing the linked list.
The basic idea is to reverse the given list to make addition easier.
We will maintain a variable ‘carry’ with an initial value ‘1’ as we have to add 1 to the given number.
Now we will traverse the list from the least significant digit, which is at the starting of the reversed list, and for each digit, we will add ‘carry’ to it.