作者zoeredbird (柔依‧紅鳥)
看板Marginalman
標題Re: 幹 今天的leetcode
時間Thu Dec 14 23:07:40 2023
509.費氏數列
class Solution(object):
def fib(self, n):
"""
:type n: int
:rtype: int
"""
if n <= 1:
return n
else:
return self.fib(n-1) + self.fib(n-2)
看到了好多新的報錯
賦值錯誤
return outside function
未定義
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.72.62.214 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1702566463.A.A5F.html
推 sustainer123: 程式課經典範例 12/14 23:33
→ SecondRun: 大師 12/14 23:37