Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: You want the maximum number of non-overlapping intervals. Which greedy rule is provably optimal?

  1. A. Earliest finish time first
  2. B. Earliest start time first
  3. C. Shortest interval first
  4. D. Latest start time first

Correct answer: A. Earliest finish time first

Picking the interval that finishes earliest leaves the most room for the rest (exchange argument). Earliest start fails on [1,10], [2,3], [4,5], where it picks only one interval but the optimum is two.

More Coding Interview Problems questions

Exams that ask this topic