LeetCode daily problem 1171. "Remove Zero Sum Consecutive Nodes from Linked List" Today's problem was a bit difficult to wrap my mind around, I used a stack to hold the values, a prefix sum, and a seen set. If a value was seen before, I popped the values until the matching seen value was encountered. I believe the time and space complexity are O(n) linear. Did you give it a try? Link to my solution.
https://github.com/cardosopab/LeetCodeNotes/blob/main/1171.py