leetcode 爬楼梯
题目:
假设你正在爬楼梯。需要 n 阶你才能到达楼顶。
每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?
注意:给定 n 是一个正整数。
有三种解决方法(本菜鸡还没想出来第四种)
递归:既耗时间,又耗空间
迭代法:省时间省空间
递归+标记数组:以空间换时间
leetcode 爬楼梯
题目:
假设你正在爬楼梯。需要 n 阶你才能到达楼顶。
每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?
注意:给定 n 是一个正整数。
有三种解决方法(本菜鸡还没想出来第四种)
递归:既耗时间,又耗空间
迭代法:省时间省空间
递归+标记数组:以空间换时间
下一篇:shell编程学习笔记
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M