696. Remove Zero Sum Consecutive Nodes from Linked List
0
Easy
Given the head of a linked list, we need to remove consecutive sequences of nodes that sum up to 0 until there are no more such sequences.
After removing these sequences, we should print the head of the final linked list.
After removing these sequences, we should print the head of the final linked list.
Input Format
The first line of input should contain the size of the linked list.
The second line of input should contain the nodes of the linked list.
The second line of input should contain the nodes of the linked list.
Output Format
Print the final linked list.
Example
Input
1 2 -3 3 4
Output
1 2 4
Constraints
The linked list provided will have a minimum of 1 node and a maximum of 1000 nodes.
Each node in the linked list will have a value between -1000 and 1000.
Each node in the linked list will have a value between -1000 and 1000.
Loading...
View Submissions
Console