Data Structures & AlgorithmsHardTCS NQT · Infosys
Meetings (start, end) are [(0, 30), (5, 10), (15, 20), (25, 40), (35, 50), (45, 60), (50, 55)]. A room can host one meeting at a time, and a meeting ending at time t frees the room for one starting at time t. What is the minimum number of rooms needed?
- A. 4
- B. 2
- C. 1
- D. 3
Correct answer: B. 2
Sweep over the sorted start and end events: +1 at a start, −1 at an end, processing ends first at equal times; the peak count is the answer. Counting intervals, or the peak minus one, misses how many meetings truly overlap at once.
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
- Balloons span the closed intervals [(1, 6), (2, 8), (7, 12), (10, 16), (3, 5), (14, 15), (8, 9)] on a horizontal line. An arrow shot at…
- Unit-time jobs are given as (deadline, profit): [(2, 100), (1, 19), (2, 27), (1, 25), (3, 15)]. Each job takes one time slot starting at…
- Jobs as (processing time, weight) are [(3, 2), (2, 1), (4, 4), (1, 3)]. They run one at a time with no idle time, and the cost is the sum…
- Tasks AAABBBCCD (each letter is a task, one unit of time each) run on a single CPU. Two identical tasks must be separated by at least n =…
- A set of symbols has frequencies [5, 9, 12, 13, 16, 45]. Huffman coding repeatedly merges the two smallest weights, and each merge costs…
- A circular route has gas stations with gas = [1, 2, 3, 4, 5, 2] and travel cost to the next station = [3, 4, 5, 1, 2, 3]. You start with…