Problem · Array

Feasibility of Printing Within Given Days

Learn this problem
MediumAgodaONSITE INTERVIEW

Problem statement

You are given an array pages, where pages[i] is the number of pages in chapter i, a fixed daily printing limit dailyLimit, and an integer days.

Chapters must be printed in order, and a chapter cannot be split across days. Return true if all chapters can be printed within days days; otherwise return false.

Function

canPrintWithinDays(pages: int[], dailyLimit: int, days: int) → boolean

Examples

Example 1

pages = [100,200,300,400]dailyLimit = 500days = 3return = true

One valid schedule is [100,200], [300], and [400], all within the daily limit of 500.

More Agoda problems

drafts saved locally
public boolean canPrintWithinDays(int[] pages, int dailyLimit, int days) {
  // write your code here
}
pages[100,200,300,400]
dailyLimit500
days3
expectedtrue
checking account