https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/
class Solution: def translateNum(self, num: int) -> int: s = str(num) n = len(s) if n == 0: return 0 if n == 1: return 1 if n == 2: if num > 25: return 1 else: return 2 m = {} m[0] = 0 m[1] = 1 i = 2 while i <= n: v = int(s[i-2:i]) if v <= 9 or v > 25: m[i] = m[i-1] elif v > 9 and v <= 25: m[i] = m[i-1]+1 i += 1 return m[n]