Merge Nodes in Between Zeros
Medium · Linked Lists · about 10 minutes
Asked at Amazon, Google, Microsoft.
A linked list starts and ends with 0 and has no two consecutive 0s. For every run of nodes between two 0s, replace the run with a single node holding its sum, and remove the 0s. Return the head of the new list.