You are viewing a single comment's thread. Return to all comments →
C++
string balancedSums(vector<int> arr) { auto sum1 = 0; auto sum2 = 0; for(std::vector<int>::iterator it = arr.begin(); it != arr.end(); ++it) { sum2 += *it; } for(std::vector<int>::iterator it = arr.begin(); it != arr.end(); ++it) { sum2 -= *it; if(sum1 == sum2) { return "YES"; } sum1 += *it; } 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 →
C++