Data Structures & AlgorithmsHardProduct company OA · Amazon/Microsoft-style OA

Meetings are closed-open intervals [1,3), [2,5), [4,6), [5,7), [6,9), [8,10) and one room can hold one meeting at a time. A meeting may start exactly when the previous one ends. What is the maximum number of meetings the room can host?

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

Correct answer: C. 3

Activity selection: sort by end time and greedily take each meeting that starts no earlier than the last chosen end. Sorting by start time or by length can block a short meeting that should have been chosen.

More Coding Interview Problems questions

Exams that ask this topic