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?

  1. A. 12
  2. B. 169
  3. C. 441
  4. 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

Exams that ask this topic