Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE

Problem: The message "2261" is decoded by mapping 1→A, ..., 26→Z. Each decoding splits the digits into groups of one or two digits, each group forming a number from 1 to 26 with no leading zero. How many different decodings exist?

  1. A. 4
  2. B. 2
  3. C. 5
  4. D. 3

Correct answer: D. 3

Count decodings with a DP over prefixes, adding one-digit and two-digit transitions when valid. Ignoring the 10 to 26 range for two-digit groups overcounts.

More Coding Interview Problems questions

Exams that ask this topic