Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Among intervals [1,6], [4,9], [5,5], [2,8], [5,7], [3,6] that contain the point 5, what is the largest number that are pairwise disjoint (closed intervals sharing a point are not disjoint)?

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

Correct answer: D. 1

Every interval here contains 5, so any two of them overlap at 5 and at most one can be chosen. The answer is therefore 1, and choosing more would violate disjointness.

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

Exams that ask this topic