Re: [閒聊] 每日LeetCode已回收
看板Marginalman作者JerryChungYC (JerryChung)時間1年前 (2024/01/18 12:53)推噓3(3推 0噓 5→)留言8則, 8人參與討論串611/719 (看更多)
https://leetcode.com/problems/climbing-stairs
70. Climbing Stairs
爬樓梯,要花 n 步
每次只能走 1 步或 2 步,問有幾種走法?
簡單來說就是費氏數列
Python3 code:
------------------------------------------------------
class Solution:
def climbStairs(self, n: int) -> int:
a, b = 1, 2
for i in range(n-1):
a, b = b, a + b
return a
------------------------------------------------------
這幾天自己寫了個py
可以自動抓每日或指定題目的code跟testcase放到電腦裡
就能直接用vscode來寫了 好耶
https://i.imgur.com/Ect124B.png

--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.227.251.103 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1705553629.A.3DC.html
→
01/18 12:53,
1年前
, 1F
01/18 12:53, 1F
推
01/18 12:54,
1年前
, 2F
01/18 12:54, 2F
→
01/18 12:54,
1年前
, 3F
01/18 12:54, 3F
→
01/18 12:55,
1年前
, 4F
01/18 12:55, 4F
→
01/18 12:56,
1年前
, 5F
01/18 12:56, 5F
→
01/18 12:59,
1年前
, 6F
01/18 12:59, 6F
推
01/18 13:05,
1年前
, 7F
01/18 13:05, 7F
推
01/18 13:10,
1年前
, 8F
01/18 13:10, 8F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 611 之 719 篇):