其本质还是斐波那契数列,不过如果用递归那么在牛客上由于限制不能通过。所以治理用非递归。
class Solution {
public:
int rectCover(int number) {
if(number < 3)
return number;
int a = 1;
int b = 2;
int c ;
for(size_t i = 3; i <= number; ++i)
{
c = a + b;
a = b;
b = c;
}
return c;
}
};