We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

I have used an implementation which takes care of that test case by itself. Here is a Java implementation which passes all test case in o(n) time.

privatestaticStringbalancedSums(List<Integer>arr){intsum=0;// get sum of all array index.for(inti=0;i<arr.size();i++){sum+=arr.get(i);}// initially left sum is zero.intleftSum=0;for(inti=0;i<arr.size();i++){//if left sum equals right sum print yes.if(leftSum==(sum-leftSum-arr.get(i))){return"YES";}leftSum+=arr.get(i);}return"NO";}

## Sherlock and Array

You are viewing a single comment's thread. Return to all comments →

I have used an implementation which takes care of that test case by itself. Here is a Java implementation which passes all test case in o(n) time.

amazing

I have also done almost similar manner.

Here is the video explanation of my solution with different approach in O(n) time-

https://youtu.be/xPHJH8RL3mo

any feedback or comment would be highly appreciated.