Decode ways

Write codeMedium25 minAmazon and Meta style

Your task

A message of digits is encoded by mapping 'A'->1, 'B'->2, ..., 'Z'->26. Given a non-empty digit string, return the number of ways to decode it back into letters. A valid single digit is 1-9 and a valid two-digit group is 10-26; a leading '0' in a group is invalid. The string length is at most 100.

Examples

num_decodings(s: str) -> int
Example 1
Inputnum_decodings("226")
Output3