dsa1 min read
Remove Zero Sum Consecutive Nodes — Prefix Sum Map
Remove consecutive nodes that sum to zero by tracking prefix sums in a map and relinking past zero-sum runs.
Read →
1575 articles
Remove consecutive nodes that sum to zero by tracking prefix sums in a map and relinking past zero-sum runs.
Split a linked list into k consecutive parts as evenly as possible, front parts get the extra nodes.
Reverse the portion of a linked list between positions left and right in one pass using careful pointer manipulation.
Find the maximum sum of twin nodes (node i + node n-1-i) by reversing the second half and comparing pairs.
Merge all nodes between 0s into a single node with their sum, modifying the list in-place.