Mathematics (JEE)HardCodeforces Div2 C

How many strings of length 5 over {1, 2, 3} have every pair of adjacent symbols differing by at most 1?

  1. A. 243
  2. B. 81
  3. C. 99
  4. D. 128

Correct answer: C. 99

Track the number of valid strings ending in 1, 2 or 3: the counts (1,1,1), (2,3,2), (5,7,5), (12,17,12), (29,41,29) give a total of 99 at length 5.

More Permutations, Combinations and Probability questions

Exams that ask this topic