Time complexity of book allocation problem

What would be its time complexity?

So we can use binary search for this problem. And there will be n no. of books are there. Now you figure it out.

PS. Prateek Bhaiya also narrated this problem in a wonderful manner.


this is my code…so binary search 's time complexity is n log n would it be same for this?

Hey @anika203a
This ispossible will be O(N) where N is the number of books.

Now that you have this, do a binary search for X(pages). Complexity is O(NlogM) where N is the number of books and M is the total number of pages.

Okay thank you so much!

1 Like

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.