Data Structures & AlgorithmsHardGATE CS · TCS NQT

Intervals [1,3), [2,4), [3,5), [0,6), [5,7), [8,9) may overlap only at endpoints (a touching endpoint is allowed). What is the minimum number of intervals to remove so the rest are pairwise non-overlapping?

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

Correct answer: B. 2

Maximise the non-overlapping set by greedy earliest-finish selection; the removals are the rest. Sorting by start time and dropping the longer of each conflict is a plausible but wrong rule.

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

Exams that ask this topic