Data Structures & AlgorithmsHardTCS NQT · Product Company SDE
Problem: A staircase can be climbed by steps of size 1, 3 or 4. How many distinct ordered sequences of steps climb exactly 13 stairs?
- A. 12
- B. 169
- C. 441
- D. 273
Correct answer: D. 273
Ordered compositions satisfy f[i] = f[i − 1] + f[i − 3] + f[i − 4] with f[0] = 1, giving f[13] = 273. Treating the steps as an unordered multiset (coin-change loop order) gives 12, and reading f[12] or f[14] by an off-by-one gives 169 or 441.
More Coding Interview Problems questions
- Problem: What is the length of the longest strictly increasing subsequence of the sequence 10, 9, 2, 5, 3, 7, 101, 18, 4, 6, 8, 1, 12?
- Problem: Coins of denominations 5, 12 and 20 are available in unlimited supply. What is the minimum number of coins needed to make exactly…
- Problem: The list [25, 14, 9, 31, 7, 18, 3, 12] is turned into a min-heap in place with heapify (standard bottom-up sift-down, 0-indexed)…
- Problem: The sorted array [2, 4, 4, 4, 7, 9, 9, 12] is searched with bisectleft and bisectright. What is bisectright(a, 4) − bisectleft(a…
- Problem: Compute (7^2026 + 11^2026) mod 1000, where ^ is exponentiation.
- Problem: Maximum number of non-overlapping meetings that can be held in one room, where a meeting is an interval [start, end) and two…