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 corrected the method and it worked.
I really didn't understand the description.
Considering that I'm not the only one like that, I need to clarify the instructions a bit at this point.
I see that there are already threads with this question.
But the instructions for this task are really misleading.
The array was: {-1, 1, 0, -1, 1, 0, -1, 1, 0, 0} - expected:<2> but was:<0>
I found the array where I have problems.
I think it is this array.
that's not a crash though is it, but wrong answer?
presumably the last one
also note that you have a return statement above where you print out an array, if that triggers you won't see that array which is the same situation as before
@natan -
Is it possible to understand on which array exactly my method crashes?
I printed all the arrays in the test group. However, looking with my eyes, I can't understand where I made a mistake, everything seems to be correct.
Thanks. Indeed, I forgot to remove 1 line of code.
that's not what the array was, that's what you printed. take greater care in what you print to see what the array was.
The array was: {16, 102, 21, 130, -20735, 7422, 88, 16, 8}: expected +0
Why should there be 0 here? Can anyone explain?
I have - expected:<0> but was:<-1> (java)
Yep, 0 is correct. When you target an index to then count to the left and right, the value stored on that index is left out meaning that at index 0, you ignore the 20 which leads to sums of 0 on both left and right.
I see where you found the 0 sum at index 0. That is just confusion. You won't get to 0 anymore if you don't count into the left and right sums the number at the target index.
So, counting the -1 at index 0 which is incorrect gets you 0 to the left and 1 to the right.
Index 2 is correct in the end.
don't use global variables (
sum_left
,sum_right
); they keep their values between tests. (also, don't use arbitrarily size arrays likeint sum_left[1000]
as you do not know for sure that they will be large enough.)duplicate of this issue
in this array, the sum to the left side of index
0
is0
, whereas the sum to the right side of index0
is1
, so the two sides are unequal at index0
. please do not open issues to ask for help, ask a question insteadHi, the test is correct. The result should be 2.
Loading more items...