Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Closed intervals [1,3], [3,5], [5,7], [2,4] must be thinned so that no two remaining intervals share even a single point. What is the minimum number of intervals to remove?

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

Correct answer: D. 2

Since the intervals are closed, touching at an endpoint counts as sharing a point, unlike half-open intervals. Removing the minimum number to make the rest pairwise disjoint gives 2 removals here.

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

Exams that ask this topic