题解 | #矩形覆盖#
矩形覆盖
http://www.nowcoder.com/practice/72a5a919508a4251859fb2cfb987a0e6
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param number int整型
# @return int整型
#
class Solution:
def rectCover(self , number: int) -> int:
# write code here
if number <= 2:
return number
dp = [0 for _ in range(number+1)]
dp[1], dp[2] = 1, 2
for i in range(3, number+1):
dp[i] = dp[i-1]+dp[i-2]
return dp[number]