题解 | #矩形覆盖#

矩形覆盖

http://www.nowcoder.com/practice/72a5a919508a4251859fb2cfb987a0e6

public class Solution {
    public int rectCover(int target) {
        if (target <= 2) {
            return target;
        }
        int[] dp = new int[target + 1];
        dp[0] = 0;
        dp[1] = 1;
        dp[2] = 2;
        for (int i = 3; i <= target; i++) {
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        return dp[target];
    }
}
全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务