Code Room
CodingHardcod-g750
Subject GreedyLevel Senior–Staff~35 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You run a single worker that can complete one job per time unit. Job i takes exactly one unit, must finish by its deadline[i] (an integer day, 1-indexed), and pays profit[i] if completed on time. You may schedule at most one job per day. Return the maximum total profit achievable. Constraints: 1 <= n <= 10^5, 1 <= deadline[i] <= n, 0 <= profit[i] <= 10^6.

Implement
max_job_profit(deadline: list[int], profit: list[int]) → int
Examples
in[[2,1,2,1,3],[100,19,27,25,15]]out142
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.