Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many ways are there to climb exactly 6 stairs taking steps of size 1, 2 or 4 (different orders of steps count as different ways)?

  1. A. 19
  2. B. 20
  3. C. 18
  4. D. 22

Correct answer: C. 18

Let w(x) be the number of ways to reach x; then w(x) = w(x-1) + w(x-2) + w(x-4), with w(0) = 1.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic