Data Structures & AlgorithmsModerateTCS NQT · Codeforces Div2 B
Closed integer intervals are [(1, 2), (3, 4), (2, 5), (6, 7), (8, 9)]. How many unordered pairs of these intervals are disjoint (share no integer point)?
- A. 8
- B. 9
- C. 2
- D. 5
Correct answer: A. 8
Closed intervals are disjoint when one ends strictly before the other starts; of the 10 pairs only (1,2)-(2,5) and (3,4)-(2,5) overlap, so 8. Treating a shared endpoint as disjoint gives 9, 2 counts the overlapping pairs and 5 the intervals.
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 ways are there to write 8 as a sum of parts, each part being 1, 2 or 3 (the order of parts matters)?
- Coins of value 2, 3 and 7 are available in unlimited supply. What is the minimum number of coins needed to make exactly 20?
- In how many ways can you choose 4 distinct numbers from 1 to 6 and list them in increasing order? (Each choice gives exactly one…
- Choose a subsequence of [4, 7, 2, 9, 5, 6, 1] with no two chosen positions adjacent, such that its total is ODD. What is the largest such…
- Count the pairs of positions (i < j) in [3, 4, 7, 2, 9, 6] such that a[i] + a[j] is odd and i + j is even.
- Choose two positions i < j with j − i ≥ 3 in [5, -4, 3, 8, -6, 2, 7]. What is the largest possible product a[i] · a[j]?