其他分享
首页 > 其他分享> > 找Bug 用例

找Bug 用例

作者:互联网

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]

  

 

标签:25,elif,return,zi,int,用例,num,Bug
来源: https://www.cnblogs.com/rsapaper/p/16163601.html