《剑指offer》跳台阶
来源:互联网 发布:怎么看淘宝成交价格 编辑:程序博客网 时间:2024/04/30 03:56
一、题目描述
一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法。
二、输入描述
输入n级台阶
三、输出描述
输出总有多少种不同跳法
四、牛客网提供的框架
class Solution {public: int jumpFloor(int number) { }};
五、解题思路
动态规划
六、代码
class Solution {public: int jumpFloor(int number) { if(number <= 2) return number; int num1, num2; num1 = 1; num2 = 2; for(int i = 3; i <= number; i++) { num2 += num1; num1 = num2 - num1; } return num2; }};
0 0
- 剑指offer-跳台阶
- 【剑指offer】跳台阶
- 剑指offer--跳台阶
- 《剑指offer》跳台阶
- 剑指Offer-跳台阶
- 《剑指offer》跳台阶
- 剑指 offer:跳台阶
- 【剑指Offer】跳台阶
- 剑指offer 跳台阶
- 剑指offer--跳台阶
- 剑指offer 跳台阶
- 《剑指offer》跳台阶
- 剑指offer-跳台阶
- 剑指offer----跳台阶
- 剑指Offer:跳台阶
- 《剑指Offer》 跳台阶
- 剑指offer--跳台阶
- [剑指offer] 跳台阶
- 利用Makefile单独编译驱动模块文件
- iOS 系统自带的表情输出与获取
- android之LinearLayout
- Android中RAS加密解密
- 接下来的这14天
- 《剑指offer》跳台阶
- 装饰器模式
- poj 3253 Fence Repair(哈夫曼)
- mina学习---了解
- 【Linux常用命令 · 复习】
- LINUX和PC之间通过串口传文件
- 大师的错误?UNP1中raw socket不能接收TCP和UDP的错误
- python字符串换行的3种方式
- 简单的socket通信 socket编程