Decoding Possibilities
STRING
DYNAMIC PROGRAMMING
Problem
Given a string of digits, determine how many ways it can be decoded into letters using the following mapping:
- "1" maps to 'A'
- "2" maps to 'B'
- ...
- "26" maps to 'Z'
Return the total number of valid decoding ways.
Examples
decodeMessage("1234") // return 3 /* Why? "1234" can be decoded as: "ABCD" (1 2 3 4) "LCD" (12 3 4) "AWD" (1 23 4) */
Loading...
Loading...Loading...