|
|
back to boardWA #6 Posted by Harry 5 Oct 2014 01:09 Please! Give me some tests. Re: WA #6 Me too!Have you solved this problem? 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 Re: WA #6 5 1 4 1 2 3 4 5 5 ans: 8 Re: WA #6 Posted by Sq1 26 Jan 2017 21:20 ty |
|
|