Loading...
A message containing letters A-Z can be encoded as numbers: 'A' -> "1", 'B' -> "2", ..., 'Z' -> "26".
Given a string s containing only digits, return the number of ways to decode it.
226
3
226 can be decoded as follows:
2 as 'B',2 as 'B',6 as 'F',
resulting in one possible decoding: 'BBF'.22 as 'V',6 as 'F',
resulting in 'VF'.2 as 'B',26 as 'Z',
resulting in 'BZ'.226 is the sum of these possibilities, which is 1+1+1=3.