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.
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.