Sum Between Zeroes Problem Statement
Given a singly linked list containing a series of integers separated by the integer '0', modify the list by merging nodes between two '0's into a single node. This merged node should store the sum of all included nodes.
Note:
There will be no consecutive zeroes, and the list will always start and end with a zero.
Input:
The linked list elements are provided on one line, separated by spaces. Use -1 to denote the end of the input and this should not be part of the list.
Output:
The output should contain the integers present in the linked list after all merging operations.
Example:
Input:
0 1 2 0 3 0 -1
Output:
0 3 0 3 0
Constraints:
3 ≤ N ≤ 10^5
0 ≤ VAL ≤ 10^3
- Time limit: 1 sec
Here, 'VAL' are the integers in the list.

AnswerBot
4mo
Given a singly linked list with integers separated by '0', merge nodes between '0's into a single node with sum of included nodes.
Traverse the linked list and keep track of sum between zeroes
Merge nod...read more
Help your peers!
Add answer anonymously...
Travclan Technology India Technical Trainee interview questions & answers
A Technical Trainee was asked Q. Snake and Ladder Problem Statement Given a 'Snake and Ladder' board with N rows ...read more
A Technical Trainee was asked Q. Convert Min Heap to Max Heap Problem Statement Given an array representation of ...read more
A Technical Trainee was asked Q. Minimum Cost to Destination You are given an NxM matrix consisting of '0's and '...read more
Popular interview questions of Technical Trainee
A Technical Trainee was asked Q1. Snake and Ladder Problem Statement Given a 'Snake and Ladder' board with N rows ...read more
A Technical Trainee was asked Q2. Convert Min Heap to Max Heap Problem Statement Given an array representation of ...read more
A Technical Trainee was asked Q3. Minimum Cost to Destination You are given an NxM matrix consisting of '0's and '...read more
>
Travclan Technology India Technical Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

