Trains the technique from
LeetCode 2187Minimum Time to Complete TripsThis 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 pottery works runs several kilns side by side. Kiln i needs cycle[i] minutes to fire one batch, and it starts the next batch the instant it finishes one, so it never idles. Every kiln loads its first batch at minute 0, and the kilns run independently of each other.
An order calls for batchesNeeded fired batches in total; it does not matter which kiln produced them.
Return the earliest whole minute at which the number of batches finished across all kilns reaches batchesNeeded. A batch counts only once its full cycle has elapsed.
Example 1
At the reported minute the three kilns have finished 4, 2 and 3 batches, which is 9 in total. One minute earlier the counts are 3, 1 and 2, which is only 6.
Example 2
Both kilns finish a batch every 7 minutes, so the finished total is 2 at minute 7, 4 at minute 14 and 6 at minute 21. The order of 5 is first met at minute 21.
Example 3
Nothing is finished at minute 1. At minute 2 the first kiln completes its opening batch, which already meets an order of one.
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 firing_minutes(cycle: list[int], batchesNeeded: int) -> int:public long firingMinutes(int[] cycle, int batchesNeeded)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.