Decode Ways

00:00
MediumDynamic ProgrammingString
AmazonFacebook

Given a string of digits, count ways to decode it where 'A'=1...'Z'=26. Each 1-2 digit sequence maps to a letter.

Examples

Input → '12'
Output → 2
Explanation:

'AB' or 'L'

Input → '226'
Output → 3
Explanation:

'BZ','VF','BBF'

Input → '06'
Output → 0
Explanation:

leading zero in '06' is invalid