剑指offer 8 跳台阶
2016-03-29 09:02
423 查看
题目描述
一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法。思路
和斐波那契数列一样的思路,f(n)=f(n-1)+f(n-2)。
public class Solution { public int JumpFloor(int target) { if(target==0)return 0; //else if(target==1)return 1; int a,b,c; a=0; b=1; c=0; while(target>0){ c=a+b; a=b; b=c; target--; } return c; } }
相关文章推荐
- SharedPreferences和序列化结合保存对象数据
- 为什么我们要造React?
- 干货分享:让你分分钟学会 javascript 闭包
- 节日来了发个HTML5红包
- 10张思维导图带你学习JavaScript
- JS 原型链图形详解
- Javascript设计模式之观察者模式
- bootstrap复习:全局样式
- jQuery UI dialog
- CSS学习(二十一)-flexbox模型之二
- javascript中的this分析
- html文本溢出
- 剑指offer-0x03
- 剑指offer-0x03
- Selenium执行JS,让隐藏区域显示正常
- JavaScript API 设计原则
- PHP实现可自定义样式的分页类
- JavaScript正则表达式(总结篇)
- 签工作offer前要弄清楚的那些事儿
- 《javaScript权威指南》随读笔记(一)