Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
On a 1 × 9 strip of cells, you place 3 non-overlapping dominoes, each covering two adjacent cells. Two dominoes may not share a cell. How many placements are there (dominoes are identical, so only the set of covered cells matters)?
- A. 20
- B. 21
- C. 24
- D. 56
Correct answer: A. 20
Dominoes may sit next to each other but not overlap. Placing k = 3 dominoes among n − 2k = 3 free cells is choosing positions for 3 dominoes among n − k = 6 objects, giving C(6, 3) = 20. Picking any 3 of the 8 start cells, C(8, 3) = 56, wrongly allows overlapping dominoes.
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 binary strings of length 9 contain exactly 4 ones and no run of three or more consecutive 0s?
- Closed integer intervals are [(1, 4), (2, 3), (5, 7), (4, 6), (8, 9), (7, 8)]. How many unordered pairs of intervals share at least one…
- The numbers [1, 6, 3, 8, 4] can be arranged in any order in a row. Maximise the sum of absolute differences between neighbouring numbers…
- Using only swaps of ADJACENT elements, what is the minimum number of swaps needed to turn [1, 2, 3, 2, 1, 3, 3] into a palindrome? (It is…
- How many contiguous subarrays of [3, 1, 3, 2, 5, 2, 5] contain exactly one occurrence of their maximum value?
- What is the length of the longest contiguous block of [1, 2, 3, 1, 2, 3, 4, 2, 3, 4] that appears at least twice in the array WITHOUT…