class Solution {
public int numWays(int n) {
if (n <= 1) {
return 1;
}
if (n == 2) {
return 2;
}
long first = 1;
long second = 2;
for (int i = 3; i <= n; i++) {
long third = first + second;
first = second;
second = third % 1000000007;
}
return (int) second;
}
}
最后
以上就是冷傲网络最近收集整理的关于面试题10- II. 青蛙跳台阶问题的全部内容,更多相关面试题10-内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复