Back to course home
0% completed
Solution: Decode Ways
Problem Statement
You have given a string that consists only of digits. This string can be decoded into a set of alphabets where '1' can be represented as 'A', '2' as 'B', ... , '26' as 'Z'. The task is to determine how many ways the given digit string can be decoded into alphabets.
Examples
-
- Input: "121"
- Expected Output: 3
- Justification: The string "121" can be decoded as "ABA", "AU", and "LA".
-
- Input: "27"
- Expected Output: 1
- Justification: The string "27" can only be decoded as "BG".
-
- Input: "110"
.....
.....
.....
Like the course? Get enrolled and start learning!