ORIGINAL CODING QUESTION
Deadline reward schedule
Each job takes one time slot and earns its nonnegative reward only if completed by its integer deadline. Slots are numbered from one. Return maximum total reward; a job can run at most once.
Original exercise · hard. Editorial role relevance does not imply a company has asked this question.
Input and output
n, then n deadline/reward pairs.
Constraints
1 ≤ n ≤ 100; 1 ≤ deadline ≤ n; 0 ≤ reward ≤ 100.
Example 1
Input
3 1 5 2 4 1 9
Output
13
Schedule reward 9 then reward 4 for total 13.
Example 2
Input
2 1 3 1 7
Output
7
Only the better job fits the sole deadline slot.
Explain your approach
Explain your time and auxiliary space complexity. Which input makes your algorithm work hardest?
Private grading inputs, expected outputs and canonical reference implementations are withheld. Authored expected outputs were cross-checked with independent reference oracles; compiler/runtime behavior still needs a verified execution provider.
Hint 1
High-reward jobs deserve consideration first.
Hint 2
Place an accepted job as late as possible before its deadline.
Hint 3
Later placement preserves earlier slots for tighter deadlines.
Practice this question
Save your work privately, explain decisions and return to your revision queue.
Open practice workspaceBrowse the question library →