Doubt in logic of the problem

why would we take starting or s = arr[n-1]. it should be arr[0] as min no of pages that can be read can be the starting element of the array . please tell me why we are not taking arr[0] as s?
and also explain why we have taken end as 0 as sum=0;?

hi @Raghavsingla522 arr[n-1] will contain the maximum amount of pages in a book.
So even if one student reads only 1 book, at least one student will have to read at least arr[n-1] pages, that is why s is taken as that.

but if he has to read only 1 book then he can read 1st book which has min pages . then why would he has to read the book with maximum pages , i.e., last book (arr[n-1])?

ALL the books have to be read. You can’t leave any books out. But the amount of pages read by 1 student, will be at least arr[n-1]because someone will have to read that book as well, right? So if that person reads just one book only, even then that’s the minimum number of pages they have to read.

You can choose s to be even 0 or anything if this is confusing you out so much, the final answer will not change since we’re also checking if “mid” can be an answer or not.