# TSECJ101 - Editorial

Contest

Author: TSEC CodeCell

Easy-Medium

### PROBLEM:

Find first index of array such that sum to the left side is equal to sum to the right side.

### QUICK EXPLANATION:

Move from left to right, keeping track of sum to left and sum to right.

### EXPLANATION:

First find total sum of array. Initialize left sum to 0 and right sum to total-a. Move from left to right, adding a[i] to left sum and subtracting a[i] from right sum. Break whenever they become equal.

### AUTHOR’S SOLUTIONS:

Author’s solution can be found here.

Your test cases do not match your constraints. The constraints says that 1 ≤ N ≤ 1000 but i guess the last test cases has N>1000.
Check this two codes.

Solution 1

Solution 2

The major difference between the two code is that Solution 1 has int arr which should work according to the given constraints but it gives Runtime Error for the last test case. Where as Solution 2 has int arr[n] which works fine.

Correct me if I am wrong.

1 Like

why binary search solution of mine is failing 3rd test case?

my submission

There were two test cases with different constraints.

For the second sub task see the constraints its 1<= N <=1000.

Both the sub task are mentioned as Sub task 1. I am talking about the second one.

Yes Shivam, you are correct. The offending test case has been removed, and we will work at rejudging the submissions. We apologise for the error and thank you for bringing it to our notice.