Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I have an issue in c++ code, in this test
vector numbers { 1,100,50,-51,1,1 };
In my IDE output is: 1, but in code wars i have output -1.
This is my code
int find_even_index (const std::vector numbers) {
int sum_r = 0;
int sum_l = 0;
for(int i = 0; i < numbers.size(); i++){
for (int l = 0; l < i; l++) {
sum_l += numbers[l];
}
for (long int r = numbers.size(); r > i; r--) {
sum_r += numbers[r];
}
if (sum_l == sum_r) {
return i;
} else sum_l = 0; sum_r = 0;
}
return -1;
}
Please help me find out what is the problem