Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Five lectures are the half-open intervals [1,2), [2,5), [4,6), [5,8), [7,9). How many lectures can be attended without overlap (touching at an endpoint is allowed)?

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

Correct answer: D. 3

Pick intervals by earliest finishing time: take [1,2), then [2,5), then [5,8), which gives three. Earliest-starting selection is worse here.

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

Exams that ask this topic