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

Merge nodes between zeroes in a singly linked list to store the sum of included nodes.

  • Traverse the linked list and keep track of sum between zeroes

  • Merge nodes between zeroes by updating the sum in the...read more

Help your peers!
Select
Add answer anonymously...

Encore Capital Group Software Developer interview questions & answers

A Software Developer was asked Q. Can you explain a real-time implementation of Object-Oriented Programming and th...read more
A Software Developer was asked Q. Connecting Ropes with Minimum Cost You are given 'N' ropes, each of varying leng...read more
A Software Developer was asked Q. Sum Between Zeroes Problem Statement Given a singly linked list containing a ser...read more

Popular interview questions of Software Developer

A Software Developer was asked Q1. Can you explain a real-time implementation of Object-Oriented Programming and th...read more
A Software Developer was asked Q2. Connecting Ropes with Minimum Cost You are given 'N' ropes, each of varying leng...read more
A Software Developer was asked Q3. Sum Between Zeroes Problem Statement Given a singly linked list containing a ser...read more
Encore Capital Group Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits