Book Allocation

Why does the montonic search space starts from the last element .
How is that the minimum number of pages a student will be reading .
Shouldn’t it be the smaller numbers like the first element.

Actually search space should start from maximum pages(ie max(a[i]) as atleast one of the students will be assigned to it. But it doesn’t matters much, you can also start your search space with 0(as long as your method to validate an answer is correct)

can you explain me the logic behind this because I am just looking at it as a way to do this question and wouldn’t be able to apply this concept anywhere else

what I understood was the monotonic search space is like minimum number o fpages possible to maximum

Binary Search is applied here as let if its possible to allocate pages such that no student gets more than x pages then its also possible with x+1,x+2,x+3… pages!
Time Complexity for BS is log(search_space) hence it doesn’t cost much difference even if your search space is from 0 to INT_MAX. What’s more important is that your search space should include the optimal point otherwise you can’t reach to answer!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.