概念
如果是dp,就同个子问题得到当前问题方程
\[F[i]=F[i-1]+F[i-2] \]代码
//优化版本
class Solution {
public:
int Fibonacci(int n) {
int front=0,tail=1;
for(int i = 0;i<n;i++){
tail += front;
front = tail-front;
}
return front;
}
};
标签:21,int,Solution,斐波,那契,dp
From: https://www.cnblogs.com/tsqo/p/16878949.html