Why s=arr[n-1]?

i dont understand this, clearly explain when to consider start=0 and sometimes we take start=arr[n-1].

how to decide ?

“The task is to assign books in such a way that the maximum number of pages assigned to a student is minimum.”

solution expected: max no of pages assigned to a student
task: to minimize the expected solution

eg. we have 4 books with 10,20,50,60 pages and have m=3.
possible solutions:

{10+20, 50,60}, ans = 60
2,{10+50,20,60} , ans = 60
{10,20,50+60}, ans = 110(max no of pages a student get = 110)
…so on
final ans = in best case(min of all possible solutions), how many max pages a student will get = 60

eg2. 10,20,30,90 and m=2
possible solutions:

{10+20,30+90}, ans = 120
2.{10+20+30,90}, ans = 90
{10+30,90+20}, ans = 110…so on
final ans = min of all possible solutions = 90

you can see that the final answer can never be less than the largest book. since atleast some student will get that book and then the solution can never be less than that.

thanks
rate and resolve if satisfied…

still u did not answered why we are starting from arr[n-1] not ZERO ?

It is because one student will at least read are[n-1] PAGES.

as i told you that the least answer will be arr[n-1]. so the search space of binary search should start from arr[n-1].
thanks

@gauravshukla789 Yes

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.