标签:col sub 输入 code size describe str scribe 描述
class Solution { public: int jumpFloor(int number) { if(number == 1) return 1; if(number == 2) return 2; return jumpFloor(number - 1) + jumpFloor(number - 2); } };
解法二、迭代
class Solution { public: int jumpFloor(int number) { int x = 1,y = 2, z; if(number == 1) return 1; if(number == 2) return 2; for(int i = 3; i <= number; ++i){ z = y; y = x + y; x = z; } return y; } };
标签:col sub 输入 code size describe str scribe 描述
原文地址:https://www.cnblogs.com/whisperbb/p/11711065.html