剑指OFFER----面试题10- II. 青蛙跳台阶问题

链接:https://leetcode-cn.com/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/

 

代码:

class Solution {
public:
    int numWays(int n) {
      std::vector<int> vec = {1, 1};

      for(int i = 2; i <= n; i++){
          vec.push_back((vec[i-2] + vec[i-1])%1000000007);
      }

      return vec[n];
    }
};

 

posted @ 2020-02-17 16:57  景云ⁿ  阅读(95)  评论(0编辑  收藏  举报