Equilibrium Indices in a Sequence

You are given an array/list named 'SEQUENCE', which consists of 'N' integers. The task is to identify all equilibrium indices in this sequence.

Explanation:

An equilibrium index is defined as a position 'i' in the sequence where the sum of elements before 'i' is equal to the sum of elements after 'i'. If no equilibrium index exists, return an empty sequence.

Input:

First line: Integer T (number of test cases) 
For each test case,
First line: Integer N (number of elements in the 'SEQUENCE')
Second line: N space-separated integers (elements of 'SEQUENCE')

Output:

For each test case, output the equilibrium indices as a sequence of integers. If none found, output an empty sequence.

Example:

Input: 
T = 2
N = 4
SEQUENCE = [1, 3, 5, 2]
N = 3
SEQUENCE = [-3, 2, 1]
Output:
[]
[1]

Constraints:

  • 1 <= T <= 50
  • 1 <= N <= 10^4
  • -10^9 <= SEQUENCE[i] <= 10^9
  • Consider the sum of elements below the first index and above the last index as 0.

Note:

The provided function implementation does not require printing the results.

AnswerBot
1y

The task is to find the equilibrium indices of a given sequence, where the sum of elements at lower indices is equal to the sum of elements at higher indices.

  • Iterate through the sequence and calculate...read more

Help your peers!
Select
Add answer anonymously...

Springworks Software Developer interview questions & answers

A Software Developer was asked Q. What is object-oriented programming?
A Software Developer was asked Q. What do you know about OOPs?
A Software Developer was asked Q. Tell me about encapsulation.

Popular interview questions of Software Developer

A Software Developer was asked Q1. What is object-oriented programming?
A Software Developer was asked Q2. What do you know about OOPs?
A Software Developer was asked Q3. Tell me about encapsulation.
Springworks 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