Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

A staircase has 10 steps. You climb 1, 2 or 3 steps at a time but may never land on step 4 or step 7. Starting at step 0, how many different sequences of moves reach step 10?

  1. A. 274
  2. B. 106
  3. C. 42
  4. D. 48

Correct answer: C. 42

Set the count of every forbidden landing step to zero and use the tribonacci-style recurrence for the rest. Forbidding only the step itself without zeroing the count lets the sequences pass through it. Ignoring the restriction entirely gives the largest count.

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

Exams that ask this topic