Using C, Sherlock and Array Solution

Aditya Tyagi
1 min readFeb 16, 2021


Watson gives Sherlock an array of integers. His challenge is to find an element of the array such that the sum of all elements to the left is equal to the sum of all elements to the right.


arr =[5,6,8,11]

8 is between two subarrays that sum to 11.

arr =[1]

The answer is [1] since left and right sum to 0.

You will be given arrays of integers and must determine whether there is an element that meets the criterion. If there is, return YES. Otherwise, return NO.

Function Description

Complete the balancedSums function in the editor below.

balancedSums has the following parameter(s):

  • int arr[n]: an array of integers


  • string: either YES or NO

Input Format

The first line contains , the number of test cases.

The next pairs of lines each represent a test case.
- The first line contains , the number of elements in the array .
- The second line contains space-separated integers where .

Sample Input 0

1 2 3
1 2 3 3

Sample Output 0


Explanation 0

For the first test case, no such index exists.
For the second test case, arr[0]+arr[1]=arr[3] , therefore index 2 satisfies the given conditions.




Aditya Tyagi

ChainReader📚, Youtuber, Programmer👨🏻‍💻, Learning filmmaking🎥, and lifetime Traveller✈️