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?
- A. 3
- B. 2
- C. 1
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Five jobs with durations [4, 3, 7, 1, 2] run one at a time on one machine. What is the minimum possible sum of waiting times (the time…
- How many index pairs i < j satisfy 3 divides a[i] + a[j] for a = [1, 2, 3, 4, 5, 6, 7]?
- How many ordered pairs (x, y) with 1 <= x, y <= 10 satisfy gcd(x, y) = 1?
- How many elements of [12, 19, 40, 7, 31, 22, 13, 8] have a decimal digit sum divisible by 4?
- How many perfect squares lie in the range [50, 250] inclusive?
- How many contiguous subarrays of [6, 10, 15, 4] have gcd exactly 1?