【发布时间】:2020-03-19 06:14:46
【问题描述】:
我在我的 IDE 中用 python 做 leetcode 70。但是它出现了错误。
class Solution:
def climbStairs(self, n: int) -> int:
cache = [None] * (n + 1)
return self._helper(n, cache)
def _helper(self, n, cache):
if n < 0:
return 0
if n == 1 or n == 0:
return 1
if cache[n]:
return cache[n]
cache[n] = self._helper(n - 1, cache) + self._helper(n - 2, cache)
return cache[n]
step = Solution.climbStairs(13)
print(step)
错误是:
`Traceback(最近一次调用最后一次): 文件“/home/viktor/PycharmProjects/70. Climbing Stairs/70. Climbing Stairs.py”,第 42 行,在 step = Solution.climbStairs(13) 类型错误:climbStairs() 缺少 1 个必需的位置参数:'n'
我该如何处理?
谢谢
【问题讨论】:
标签: python class methods call self