Trains the technique from
LeetCode 209Minimum Size Subarray SumThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A field engineer logs the hours worked on each day of a tour, day by day, in hours.
Payroll wants to credit one unbroken run of days whose logged hours add up to quota or more, and it wants that run to cover as few days as it can. The run has to be consecutive days: skipping a day inside it is not allowed.
Return the number of days in the shortest qualifying run. When no run of consecutive days reaches quota, return 0.
Example 1
The days logging 5, 1 and 6 add up to 12, which clears the quota with three days. No pair of neighbouring days gets past 9, so two days are never enough.
Example 2
The final day alone logs 10 and clears the quota, so a single day is the shortest run even though the whole tour also qualifies.
Example 3
The entire tour logs only 6 hours, so no run can reach 100 and the answer falls back to 0.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def fewest_shifts_for_quota(quota: int, hours: list[int]) -> int:public int fewestShiftsForQuota(int quota, int[] hours)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.