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!
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.
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

