ECAUG205 - Notebook Distribution - Help

This is My solution.

I simply used binary search, searched for the value, if the value is more or equal than the needed books, set low = mid, else set high = mid. Then I returned low. However, the solution was wrong, I tried to debug it many time but no AC.

Can you tell me why the code is wrong or I’m just missing a few corner cases.

Hi. I made a few changes to your Binary Search algorithm and got AC.

1 Like

what should be the wrong testcase for my code ?

5 10
1 1 1 1 1
The correct output is 0 but your code gives 1 as the output.

1 Like

Thank you so much for helping, it turns out that simply changing the low from 1 to 0 solve the problem. I didn’t expect a condition where the book has no pages.

1 Like

@bubu2006 have a look at the editorial, it might be helpful.
ECAUG205 - Editorial