Trains the technique from
LeetCode 455Assign CookiesThis 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 scheduler is about to launch a queue of jobs on one machine. You are given an integer array need, where need[i] is the amount of scratch memory that job i must be handed before it will launch, and an integer array blocks, where blocks[j] is the size of the j-th free block of scratch memory.
A job launches only if it is handed a single whole block whose size is at least its requirement. Blocks are never split and never shared, so each block goes to at most one job and each job takes at most one block. Some jobs may be left unlaunched.
Return the largest number of jobs that can be launched.
Example 1
Hand the 5-unit block to the job that needs 4 and the 12-unit block to the job that needs 9. Both blocks are at least as large as the requirement they cover, so 2 jobs launch.
Example 2
Every free block holds 2 units, which is below all three requirements, so no job can be handed a block it accepts.
Example 3
The 1-unit block covers the job that needs 1 and the 6-unit block covers one of the jobs that needs 5. The only block left holds 2 units, which is below the remaining requirement of 5, so that job stays unlaunched and the count is 2.
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 max_jobs_started(need: list[int], blocks: list[int]) -> int:public int maxJobsStarted(int[] need, int[] blocks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.