

If the given linked list is 3 ->4 ->0 ->5 ->0, you should return linked list as - 7 -> 5.
You need to replace the sum values in the linked list without using any extra space.
It is guaranteed that there will be no two consecutive zeroes in the linked list.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains integers denoting the nodes of the linked list. Each line is guaranteed to have -1 at the end to signify the end of the linked list. Also, None of the elements of the linked list is -1.
For each test case, print space-separated integers denoting the nodes of the output linked list, in a separate line.
Each new line denotes a separated linked list.
You don't need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 10^5
-10^9 <= data <= 10^9
data ≠ -1.
Time Limit: 1 sec
The simple idea is to traverse the linked list and store the sum of nodes in a variable ‘sum’ until ‘0’ is not encountered. We will store this ‘sum’ value in every series’s first node and link all these nodes containing sum values.
Algorithm:
Let us understand the above approach with an example.