class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
if n <= 2:
return n
last =1
nexttolast = 1
sums = 0
for i in range(2,n+1):
sums = last+nexttolast
nexttolast = last
last = sums
return sums
相关文章
- 01-03[LeetCode] 746. Min Cost Climbing Stairs
- 01-03[LeetCode&Python] Problem 27. Remove Element
- 01-03LeetCode题解(1387):将整数按权重排序(Python)
- 01-03LeetCode题解(1310):子数组异或查询(Python)
- 01-03❤leetcode,python2❤从排序数组中删除重复项
- 01-03❤leetcode,python2❤最大子序和
- 01-03LeetCode-239-剑指offer-滑动窗口的最大值-队列与栈-python
- 01-03[LeetCode][Python]Longest Palindromic Substring
- 01-03leetcode557. 反转字符串中的单词 III python,处理字符串的神!
- 01-03【LeetCode】297. Serialize and Deserialize Binary Tree 解题报告(Python)