摘要: # 如果fib函数执行次数过多时,通过装饰器来改进效率# 我们可以用字典来保存计算过的结果,防止重复def memoize(f): memo = {} def helper(x): if x not in memo: memo[x] = f(x) return memo[x] return help 阅读全文
posted @ 2021-05-16 23:39 夜晚的潜水艇 阅读(58) 评论(0) 推荐(0)