Data Structures & AlgorithmsModerateProduct company OA · Amazon/Microsoft-style OA
A 2 x 7 board is to be covered by 1 x 2 dominoes (each may be placed horizontally or vertically). How many tilings are there? Use the classic 2 x n domino recurrence.
- A. 29
- B. 17
- C. 21
- D. 128
Correct answer: C. 21
For a 2 x n board, the number of domino tilings satisfies f(n) = f(n-1) + f(n-2) with f(0) = 1 and f(1) = 1, giving Fibonacci numbers. The sequence grows by one step each column, and a 2 x 7 board corresponds to the 8th Fibonacci number.
More Coding Interview Problems questions
- Arrays A = [2, 3, 5, 7, 4] and B = [6, 10, 1, 3, 8]. How many pairs (x in A, y in B) satisfy x y = 24?
- Weighted intervals (start, end, value): (0,5,4), (3,9,6), (6,10,3), (9,12,5). Choose two intervals that do not overlap (touching at an…
- Array a = [-2, 5, -1, 4, -3, 6]. How many contiguous subarrays have a sum strictly between 0 and 10?
- Sorted array [2, 3, 7, 9, 12, 15, 18]. How many index pairs i < j have a difference srt[j] - srt[i] in the range (3, 8], i.e. greater than…
- How many integers x with 1 <= x <= 30 have a binary representation with no two adjacent 1-bits?
- From the ten numbers [3, 8, 12, 5, 7, 10, 1, 4, 9, 6], how many 3-element subsets have a sum divisible by 5?