Java教程

找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]

  

 

这篇关于找Bug 用例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!