Re: WA #6

I have this WA too.

Firstly, I used binary search to find the last element, which didn't fall.

And my mistake was:

if (currentSum == k)

return med;

the corrent ones:

if (currentSum == k)

return med-1;

And for case, where we haven't found exactly k sum:

..

}//end of binary search

int answerIndex = l;

int sum = getSum(left, lastAdded Index);

if (sum <= k){

answerIndex = l - 1;

}

return answerIndex;

But now I have TL11