Equilibrium Index Problem Statement

Given an array Arr consisting of N integers, your task is to find the equilibrium index of the array.

An index is considered as an equilibrium index if the sum of elements of the array to the left of that index is equal to the sum of elements to the right of it.

Input:
The first line contains an integer T, representing the number of test cases.
The first line of each test case contains an integer N, representing the size of the array.
The second line of each test case contains N space-separated integers representing the array elements.
Output:
The output for each test case should be a single integer indicating the equilibrium index of the array.

Example:

Input:
1
5
-7 1 5 2 -4

Output:
2
Explanation:

The index 2 is an equilibrium index because the sum of elements on its left (-7 + 1) equals the sum of elements on its right (2 - 4).

Constraints:

  • 1 <= T <= 50
  • 1 <= N <= 10^5
  • -10^4 <= Arr[i] <= 10^4

Note:

  • The array uses 0-based indexing, so return the 0-based index of the equilibrium.
  • The element at the equilibrium index is not considered in the sum for either side.
  • If multiple indices meet the condition, return the left-most one.
  • If no such index is present, return -1.
AnswerBot
4mo

Find the equilibrium index of an array where sum of elements on left equals sum on right.

  • Iterate through the array and calculate the total sum of all elements.

  • For each index, calculate the left sum an...read more

Help your peers!
Select
Add answer anonymously...

Accenture Associate Software Engineer interview questions & answers

An Associate Software Engineer was asked 1w agoQ. Which technology stack have you worked with?
An Associate Software Engineer was asked 6mo agoQ. What is OOPS?
An Associate Software Engineer was asked 6mo agoQ. What are different approaches to swap two variables without using a third variab...read more

Popular interview questions of Associate Software Engineer

An Associate Software Engineer was asked 5mo agoQ1. What is OOPS?
An Associate Software Engineer was asked 6mo agoQ2. What are different approaches to swap two variables without using a third variab...read more
An Associate Software Engineer was asked 6mo agoQ3. Write a function to remove duplicates from a list in O(n) time complexity.

Top HR questions asked in Accenture Associate Software Engineer

An Associate Software Engineer was asked 2w agoQ1. Have you ever encountered a project issue with a teammate who unexpectedly left,...read more
An Associate Software Engineer was asked 2w agoQ2. Can you share something about yourself that is not included in your resume?
An Associate Software Engineer was asked 1mo agoQ3. What challenges did you face as a team leader during the project?
Accenture Associate Software Engineer 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