You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/-kwepBHt_jM
string balancedSums(vector<int> arr) { int ls = 0, rs = accumulate(arr.begin(), arr.end(), 0); for(int i = 0; i < arr.size(); i++){ rs -= arr[i]; if(i != 0) ls += arr[i-1]; if(ls == rs) return "YES"; } return "NO"; }
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 →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/-kwepBHt_jM