Two ways
Input
num_decodings('12')
Output
2
'12' can be decoded as 'AB' (1,2) or 'L' (12).
Full lesson preview
Count the number of ways to decode a digit string where '1'->'A' ... '26'->'Z' using dynamic programming.
Problem statement
Task
Examples
Input
num_decodings('12')
Output
2
'12' can be decoded as 'AB' (1,2) or 'L' (12).
Input format
Output format
Constraints
Samples
Input
num_decodings('226')
Output
3
'226' -> 'BZ' (2,26), 'VF' (22,6), 'BBF' (2,2,6)