leetcode Climbing Stairs python
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
leetcode Climbing Stairs python的更多相关文章
- [LeetCode] Climbing Stairs 爬梯子问题
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- Leetcode: climbing stairs
July 28, 2015 Problem statement: You are climbing a stair case. It takes n steps to reach to the top ...
- [LeetCode] Climbing Stairs (Sequence DP)
Climbing Stairs https://oj.leetcode.com/problems/climbing-stairs/ You are climbing a stair case. It ...
- 746. Min Cost Climbing Stairs@python
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay ...
- LeetCode——Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- LeetCode:Climbing Stairs(编程之美2.9-斐波那契数列)
题目链接 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either c ...
- [Leetcode] climbing stairs 爬楼梯
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- [LeetCode] Climbing Stairs 斐波那契数列
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- [LeetCode] 70. Climbing Stairs 爬楼梯
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
随机推荐
- velocity的foreach下标
velocity的foreach标签操作: #foreach( $per in ${list} ) #end 如果需要访问循环的当前目标的index可用通过${velocityCount},其默认是从 ...
- api (二) 创建控件 (转)
在Win32 SDK环境下,怎么来创建常用的那些基本控件呢?我们知道如果用MFC,简单的拖放即可完成大多数控件的创建,但是我们既然是用Windows SDK API编程,当然是从根上解决这个问题,实际 ...
- gtest的Linux使用(Google test)
GTest是Google开发的跨平台而且开源的C++单元测试框架,很好很强大. 下载地址:https://code.google.com/p/googletest/ . 关于GTest在Windows ...
- Android 通过HTTPCLINET POST请求互联网数据
private EditText et; private TextView tv; HttpClient client; @Override protected void onCreate(Bundl ...
- Linux网络管理——ISO/OSI七层模型
1. 网络基础 1. 网络基础 1.1 iso/osi七层模型 事前声明: ISO:国际标准化组织 OSI:开放系统互联模型 IOS:苹果操作系统 但是在计算机网络当中,IOS是互联网操作系统,是思科 ...
- css3之border-color
-moz-border-top-colors:上边框-moz-border-right-colors:右边框-moz-border-bottom-colors:下边框-moz-border-left- ...
- xampp环境安装swoole
手动编译php运行环境经常遇到函数库依赖的问题,这个错误搞定了,又蹦出来那个错误,很棘手,为了快速搭建一个swoole开发环境,于是另辟蹊径,直接下载安装xampp for linux,然后在用xam ...
- swift 创建tableView并实现协议
// // ViewController2.swift // swift_helloword // // Created by Charlie on 15/7/13. // Copyright (c) ...
- 【Chromium中文文档】进程模型
进程模型 转载请注明出处:https://ahangchen.gitbooks.io/chromium_doc_zh/content/zh//General_Architecture/Process_ ...
- Oracle EBS-SQL (SYS-21):sys_用户名与人员对应关系查询.sql
select fu.user_name 用户名, fu.description 描述, (select ppf.FULL_NAME ...