java.lang.Object
g1101_1200.s1171_remove_zero_sum_consecutive_nodes_from_linked_list.Solution

public class Solution extends Object
1171 - Remove Zero Sum Consecutive Nodes from Linked List.<p>Medium</p> <p>Given the <code>head</code> of a linked list, we repeatedly delete consecutive sequences of nodes that sum to <code>0</code> until there are no such sequences.</p> <p>After doing so, return the head of the final linked list. You may return any such answer.</p> <p>(Note that in the examples below, all sequences are serializations of <code>ListNode</code> objects.)</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> head = [1,2,-3,3,1]</p> <p><strong>Output:</strong> [3,1] <strong>Note:</strong> The answer [1,2,1] would also be accepted.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> head = [1,2,3,-3,4]</p> <p><strong>Output:</strong> [1,2,4]</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> head = [1,2,3,-3,-2]</p> <p><strong>Output:</strong> [1]</p> <p><strong>Constraints:</strong></p> <ul> <li>The given linked list will contain between <code>1</code> and <code>1000</code> nodes.</li> <li>Each node in the linked list has <code>-1000 <= node.val <= 1000</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details