Remove Zero Sum Consecutive Nodes from Linked List
Medium · Linked Lists · about 20 minutes
Asked at Amazon, Microsoft, Google, Meta.
While the list contains some run of consecutive nodes whose values total 0, cut that run out. Stop when no such run is left and return the head. In general the end result could depend on which runs you cut first, but each test here allows only one outcome.