Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // you can also use includes for example:
- // #include <algorithm>
- unsigned long long sum(const vector<int> v) {
- unsigned long long total = 0;
- for(int i = 0; i < v.size(); ++i) {
- total += v[i];
- }
- return total;
- }
- int equi ( const vector<int> &A ) {
- int size = A.size();
- unsigned long long front = 0, back = sum(A);
- for(int i = 0; i < size; ++i) {
- back -= A[i];
- if(front == back) return i;
- front += A[i];
- }
- return -1;
- }
Add Comment
Please, Sign In to add comment