Data Structures & AlgorithmsHardProduct Company SDE · CAT · MBA placement

Problem: Maximum number of non-overlapping meetings that can be held in one room, where a meeting is an interval [start, end) and two meetings may touch at an endpoint. The intervals are [1,4), [3,5), [0,6), [5,7), [3,9), [5,9), [6,10), [8,11), [8,12), [2,14), [12,16). What is the maximum?

  1. A. 5
  2. B. 4
  3. C. 3
  4. D. 6

Correct answer: B. 4

The earliest-finishing greedy rule is optimal for interval scheduling. Sorting by start time instead of end time can give a wrong count.

More Coding Interview Problems questions

Exams that ask this topic