Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

(This question is a variation of the LeetCode question 875. Koko Eating Banana. If you haven't completed that question yet, it is recommended to solve it first.)

A student is preparing for a test for a scholarship.

The student is required to completely read n chapters (which is the length of the pages array) for the test, where the ithi^{\text{th}} chapter has pages[i] number of pages. The chapters are read in increasing order of the index. Each day, the student can either read till the end of a chapter or at most x pages, whichever is minimum. The number of pages remaining to read decreases by x in the latter case.

Test Cases
Input
Output
Expected