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

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/1171.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub