本文主要是介绍剑指 offer 小青蛙跳台阶,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
class Solution {
public:int jumpFloor(int number) {int array[2] = {0,1};if (number<2){return array[number];}else{long long one =1;long long two =1;long long sum =0;for (long long i = 2;i<=number;i++){sum = one + two;one = two;two = sum;}return sum;}}
};
这篇关于剑指 offer 小青蛙跳台阶的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!