题解 | #矩形覆盖#
矩形覆盖
https://www.nowcoder.com/practice/72a5a919508a4251859fb2cfb987a0e6
class Solution { public: int rectCover(int number) { if(number == 0) return 0;//根据约定,返回0 vector<int> dp(number+1, 1); dp[1] = 1; dp[2] = 2; for(int i = 3; i <= number; ++i) { dp[i] = dp[i-1] + dp[i-2];//找规律,当前的是上次和上上次的总和 } //std::cout << dp[number] << std::endl; return dp[number]; } };
挤挤刷刷! 文章被收录于专栏
记录coding过程