矩形覆盖:斐波那契数列问题
矩形覆盖
http://www.nowcoder.com/questionTerminal/72a5a919508a4251859fb2cfb987a0e6
依旧是典型的斐波那契数列问题
两种方法,递归调用和迭代。 提交后两者的运行时间相差一百多倍
class Solution { public: int rectCover(int number) { if(number<=3)return number; //return rectCover(number-1)+rectCover(number-2); int a,b,c; a=2;b=3; for(int i=4;i<=number;++i){ c=a+b; a=b; b=c; } return c; } };