Animate the Job Sequencing with Deadlines algorithm. See how sorting by profit and assigning each job to the latest available slot maximizes total profit.
Given N jobs, each with a deadline and profit. Each job takes 1 unit of time. Only one job runs at a time. Maximize total profit by scheduling as many high-profit jobs as possible before their deadlines.
Sort jobs by profit (descending). For each job, try to assign it to the latest available time slot at or before its deadline. This greedy choice maximizes profit without blocking higher-profit jobs.
Scan slots from deadline-1 down to 0. Assign the job to the first free slot found. If no slot is available, reject the job.
O(N²) with linear slot search. Optimizable to O(N log N) using Union-Find for slot lookup. Space O(N) for the slots array.