Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

Meetings occupy the half-open intervals [s, f) listed as (1,2), (3,4), (0,6), (5,7), (8,9), (5,9). Only one meeting may use the room at a time, and a meeting may start exactly when another ends. What is the maximum number of meetings held?

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

Correct answer: C. 4

Greedy by earliest finish picks (1,2), (3,4), (5,7), (8,9), which is optimal. Sorting by start time would take (0,6) first and lose a meeting.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic