Data Structures & AlgorithmsHardGATE CS · TCS NQT
How many ways can the digit string 226 be decoded when 1 to 26 map to A to Z?
- A. 4
- B. 3
- C. 5
- D. 7
Correct answer: B. 3
Decode as 2-2-6 (BBF), 22-6 (VF), and 2-26 (BZ): three ways. The DP over prefixes adds the one-digit and two-digit cases.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the length of the longest substring of banana that appears at least twice in the string (occurrences may overlap)?
- Evaluate the Reverse Polish expression 10 6 9 3 + -11 / 17 + 5 +. What is the result?
- How many integers x in [1, 1000] have exactly 4 positive divisors?
- How many integers n with 1 <= n <= 200 have exactly 6 trailing zeros in n! (written in base 10)?
- What is the sum of all integers in [1, 100] whose digit sum is prime?
- A snail climbs a well of height 10 metres. Each day it climbs 3 metres; each night it slides back 2 metres. It stops when it first reaches…