Split Array with Equal Sums Problem Statement

Given an array 'ARR' of size 'N', determine if there exists a triplet (i, j, k) satisfying the conditions: 0 < i , i + 1 < j , j + 1 < k and k < N - 1, such that the sums of the subarrays [0, i - 1], [i + 1, j - 1], [j + 1, k - 1], [k + 1, N - 1] are equal.

Example:

Input:
ARR = [1, 2, 3]
Output:
False
Example Explanation:

The possible subarrays of 'ARR' are {1}, {2}, {3}, {1, 2}, {2, 3}, {1, 2, 3}. No such triplet satisfying the required condition exists in this case.

Constraints:

  • 1 ≤ T ≤ 5
  • 1 ≤ N ≤ 10 ^ 3
  • -10 ^ 6 ≤ ARR[i] ≤ 10 ^ 6
Note:

An array c is a subarray of array d if c can be obtained from d by deletion of several elements from the beginning and several elements from the end.
Assume that the array has zero-based indexing.

Input format:

The first line of input contains an integer ‘T’ representing the number of test cases. Each test case consists of: The first line: An integer ‘N’ indicating the size of the array. The second line: 'N' space-separated integers representing the elements of the array.

Output format:

For each test case, print 'True' if such a triplet exists; otherwise print 'False'. Output is presented as separate lines for each test case.

Note:

You are not required to take input or print anything. Just implement the function.
AnswerBot
4mo

The problem involves determining if there exists a triplet in an array such that the sums of specific subarrays are equal.

  • Iterate through all possible triplets (i, j, k) satisfying the given condition...read more

Help your peers!
Select
Add answer anonymously...

Capgemini Software Developer interview questions & answers

A Software Developer was asked 2d agoQ. Write a program to print prime numbers from 1 to 100.
A Software Developer was asked 1mo agoQ. What is the difference between method overriding and method overloading?
A Software Developer was asked 2mo agoQ. What is Java?

Popular interview questions of Software Developer

A Software Developer was asked 2d agoQ1. Write a program to print prime numbers from 1 to 100.
A Software Developer was asked 1mo agoQ2. What is the difference between method overriding and method overloading?
A Software Developer was asked 2mo agoQ3. What is Java?
Capgemini 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