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.
publicstaticStringbalancedSums(List<Integer>arr){// Write your code hereintsum=0;for(Integere:arr){sum+=e;}intsum1=0;intsum2=sum;arr.add(0,0);arr.add(0);for(inti=1;i<arr.size()-1;i++){sum1+=arr.get(i-1);sum2-=arr.get(i);if(sum1==sum2)return"YES";}return"NO";}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Array
You are viewing a single comment's thread. Return to all comments →
Java Code: