Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE

Problem: Starting from 5 on a number line, you may jump +2 or +3 each turn and must land exactly on 25. How many distinct jump sequences achieve this?

  1. A. 4
  2. B. 114
  3. C. 86
  4. D. 465

Correct answer: B. 114

f(p) = f(p + 2) + f(p + 3) from 5 up to 25 counts 114 ordered sequences. The jump multisets (2a + 3b = 20) number only 4, starting from 6 gives 86, and starting from 0 gives 465.

More Coding Interview Problems questions

Exams that ask this topic