Find Minimum Days
Learn this problemProblem statement
A student is preparing for a scholarship test which is organized on the Amazon Academy platform and scheduled for next month.
There are n chapters to be studied, where the i-th chapter has pages[i] pages. On each day, the student chooses some window of exactly k consecutive chapters. From each chapter in that chosen window, the student reads up to p of its remaining pages: the remaining page count of every chapter in the window is reduced by p. If a chapter has fewer than p pages remaining, the student reads all of its remaining pages and its remaining page count becomes 0 (it never goes negative). A chapter already at 0 remaining pages may still lie inside a chosen window; it simply stays at 0.
Find the minimum number of days the student needs so that the remaining page count of every chapter is 0.
Note: The k chapters chosen each day must be contiguous, and each chosen window must lie fully within the chapters (its starting index ranges over 0 to n - k).
Function
findMinimumDays(pages: int[], k: int, p: int) → longComplete the function findMinimumDays in the editor below.
findMinimumDays has the following parameters:
int pages[n]: the number of pages in each chapterint k: the number of consecutive chapters chosen each dayint p: the maximum number of pages read from each chosen chapter in a day
Returns
long int: the minimum number of days needed so that all chapters have 0 remaining pages.
Examples
Example 1
pages = [3, 1, 4]k = 2p = 2return = 4Example 2
pages = [3, 4]k = 1p = 2return = 4Constraints
1 ≤ n ≤ 10^51 ≤ pages[i] ≤ 10^91 ≤ k ≤ n1 ≤ p ≤ 10^9
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026