(self, s: str)
| 5 | ''' |
| 6 | class Solution: |
| 7 | def numDecodings(self, s: str) -> int: |
| 8 | if not s or s[0]=='0': |
| 9 | return 0 |
| 10 | dp = [0]*(len(s)+1) |
| 11 | dp[0],dp[1] = 1,1 |
| 12 | for j in range(2,len(s)+1): |
| 13 | i = j-1 |
| 14 | a = int(s[i]) |
| 15 | b = int(s[i-1:i+1]) |
| 16 | if 0<a<10: |
| 17 | dp[j]=dp[j-1] |
| 18 | if s[i-1]!='0' and 0<b<27: |
| 19 | dp[j]+=dp[j-2] |
| 20 | return dp[-1] |
| 21 | |
| 22 | |
| 23 | ##Improved |
nothing calls this directly
no outgoing calls
no test coverage detected