Practice Merge Nodes in Between Zeros
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given the head of a linked list, which contains a series of integers separated by 0's. The beginning and end of the linked list will have Node.val == 0. For every two consecutive 0's, merge all the nodes lying in between them into a single node whose value is the sum of all the merged nodes. The modified list should not contain any 0's. Return the head of the modified linked list.
Source: Merge Nodes in Between Zeros on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
head = [0,3,1,0,4,5,2,0]
[4,11]
# Example 2
head = [0,1,0,3,0,2,2,0]
[1,3,4]
Constraints
Related LeetCode Problems
Practice more problems similar to Merge Nodes in Between Zeros.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.