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 ...
随机推荐
- update慢怎样处理?
update慢: 1.表的pctfree參数设置? 2.运行计划用索引还是全表扫? 3.SQL语句写法问题? 4.update慢还是commit慢? 5.更新多少条数据? 6.表是否频繁update造 ...
- JAVA装饰器模式
Java程序员们应该对java.io对不会陌生,因为java.io包采用了装饰器模式. 一.定义: Decorator装饰器,顾名思义,就是动态地给一个对象添加一些额外的职责,就好比为房子进行装修一样 ...
- C#中的USB库 WinUSB
NET C#中的USB库WinUSB,的libusb - Win32和的libusb - 1.0.使用公共设备类,应用程序与所有未经修改的操作系统和驱动程序.大量的示例代码. http://sourc ...
- WinForm DataGridView看似刷新的问题
昨天同事winform遇到一个问题, 窗体上有一个时间控件,和一堆文本,下拉控件,时间控件是每秒都在动态走的 窗体下发一个DataGridView 控件显示保存后的数据 保存的数据库是在另一台机器B上 ...
- 《Microsoft SQL Server企业级平台管理实践》笔记
- 页是 SQL Server 中数据存储的基本单位,大小为 8KB. - 区是空间管理的基本单位,8个物理上连续的页的集合(64KB). - 页的类型包括: 1. Data 2. Index 3. ...
- AngularJs 常用函数
/** * [intersect 取两个数组的交集] var firstArray = [1,3,5]; var secondArray = [2,5,8]; var result */ .filte ...
- QF——UI之UIViewController
程序一经启动,AppDelegate的实例就会创建一个充满屏幕的window,它是App唯一的,一个App对应一个window.window是UIWindow类型的,继承于UIView,是种特殊的UI ...
- mysql sql学习(一)mysql连接
mysql -h 192.168.3.103 -uroot -p123456 //连接数据库 \s :查看数据库状态 show databases; 查看是数据库 create database if ...
- Android 动画系列
Android种最常用的动画: ~1~Tween动画,就是对场景里的对象不断的进行图像变化来产生动画效果(旋转.平移.放缩和渐变) Tweene Animations 主要类: Animation ...
- MySQL远程(IP)连接报错:Host 'IP地址' is not allowed to connect to this MySQL server
ERROR 1130: Host ’192.168.1.3′ is not allowed to connect to this MySQL server这是告诉你没有权限连接指定IP的主机,下面我们 ...