Data Structures & AlgorithmsHardGATE CS · TCS NQT
Meetings are [0,30), [5,10), [15,20), [35,45), [40,50). A meeting ending at time t and another starting at t can share a room. What is the minimum number of rooms?
- A. 3
- B. 2
- C. 1
- D. 4
Correct answer: B. 2
The answer is the maximum number of meetings active at any moment, found by a sweep. Here [0,30) overlaps with [5,10) and [15,20) at once, giving two rooms at a time, and the later pair does not raise the maximum above two.
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
- What is the sum of the minimum over every window of size 2 in [5, 2, 8, 1, 9]?
- How many ordered pairs (a, b) with 1 <= a, b <= 10 satisfy a^2 + b^2 <= 50?
- How many integers from 1 to 64 inclusive are either a power of two or have exactly two 1-bits in binary?
- What is the length of the longest palindromic subsequence of "bbbab"?
- Trains arrive at times 2, 4, 4, 6, 8 and depart at 3, 5, 7, 6, 9 (a departure at the same time as an arrival frees its platform first)…
- What is the sum of the positive divisors of 60 that are at most 10?