What is the complexity of Book allocation Code

Kindly help me with the complexity

Hey @EkanshJain2323
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.