Data Structures & AlgorithmsHardProduct Company SDE · Amazon OA

Problem: Job sequencing: five jobs (deadline, profit) are (2, 100), (1, 19), (2, 27), (1, 25), (3, 15). Each job takes one unit of time and at most one job runs per unit time; a job earns its profit only if it finishes by its deadline. What is the maximum total profit?

  1. A. 152
  2. B. 140
  3. C. 142
  4. D. 127

Correct answer: C. 142

Sort by profit and place each job in the latest free slot before its deadline: 100 in slot 2, 27 in slot 1, 25 and 19 find no slot, 15 in slot 3 → 142. Ignoring deadlines (top three profits) gives 152, scheduling by earliest deadline first picks 25 over 27 (140), and using only two slots gives 127.

More Coding Interview Problems questions

Exams that ask this topic