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?
- A. 4
- B. 2
- C. 5
- 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
- Problem: 23 people stand in a circle numbered 1 to 23. Starting at person 1, every second person is eliminated (counting around the…
- Problem: Eight cards labelled 1 to 8 are in a row. A perfect out-shuffle splits the deck into two equal halves (1–4 and 5–8) and…
- Problem: Lamps 1 to 20 are all off. For each pass i = 1 to 20, every lamp whose number is a multiple of i is toggled. How many lamps are…
- Problem: Count integers from 1 to 100 that are divisible by 3 or by 5 but not by 15.
- Problem: Compute 2^(2^5) mod 1000 (that is, 2 raised to the power 32, taken modulo 1000).
- Problem: With coin denominations 1, 7 and 10, what is the minimum number of coins needed to make 97?