Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
How can you use two pointers to modify the original list into the new list?
Have a pointer traverse the entire linked list, while another pointer looks at a node that is currently being modified.
Keep on summing the values of the nodes between the traversal pointer and the modifying pointer until the former comes across a ‘0’. In that case, the modifying pointer is incremented to modify the next node.
Do not forget to have the next pointer of the final node of the modified list point to null.