Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
In how many ways can a 3 × 8 rectangle be tiled exactly with 2 × 1 dominoes (horizontal or vertical)?
- A. 41
- B. 306
- C. 162
- D. 153
Correct answer: D. 153
Let f(n) be the number of tilings of a 3 × 2n board: with f(0) = 1 and f(1) = 3, the recurrence f(n) = 4f(n−1) − f(n−2) holds, since the transfer structure of the boundary gives exactly these two new patterns. Doubling the count mirrors the board and is a common error.
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 DIFFERENT values can the sum of three distinct integers chosen from 1 to 9 take?
- What is the length of the longest substring of "aebcdiouxyab" in which the number of vowels (a, e, i, o, u) equals the number of non-vowels?
- How many index pairs (i < j) in [4, 9, 1, 7, 12, 5, 8, 3] satisfy a[i] − a[j] = 3 (exactly 3, in this order)?
- Starting from the number 1, each operation either doubles the current number or adds 1. What is the minimum number of operations needed to…
- How many pairs (i, j) with 1 ≤ i ≤ j ≤ 12 have lcm(i, j) ≤ 12?
- Coins of values 1, 4, 9 and 16 are available in unlimited supply. What is the minimum number of coins that makes exactly 27?