Dsa
Arrays
Easy
Balanced Sums
Given an array of integers, find the index of the element that splits the array into two parts with equal sum. If no such index exists, return -1.
Input:
The first line contains an integer n (1 <= n <= 10^5), the length of the array.
The second line contains n space-separated integers, the elements of the array.
Output:
Return the index of the element that, if removed, causes the sum of the remaining elements to be equal on both sides. If no such index exists, return -1.
Example:
Input:
5
1 2 3 3 2
Output:
2
Key concepts
arraysprefix sumbalance
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now