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?
- A. 3
- B. 1
- C. 0
- 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.
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
- How many ordered pairs (a, b) with 1 <= a, b <= 6 have a^2 + b^2 a perfect square?
- Apply the operations push 3, push 5, pop, push 7, push 2, pop, pop to an initially empty stack. What is the sum of the values remaining on…
- Starting at step 0, you climb to step 6 taking steps of 1 or 2 each time. How many distinct sequences of steps are possible?
- How many integers from 1 to 1000 inclusive are divisible by 8 and have an even number of 1-bits in binary?
- Repeatedly merge two values into their sum at cost equal to that sum, starting from [1, 2, 3, 4]. What is the minimum total cost?
- How many integers from 1 to 100 inclusive have an odd number of positive divisors?