class Solution {
public int fib(int n) {
if(n < 2) return n;
int a = 0;
int b = 1;
int c = 0;
for(int i = 1; i < n;i++){
c = a + b;
a = b;
b = c;
}
return c;
}
}
代码随想录——509. 斐波那契数
最新推荐文章于 2024-11-03 16:33:21 发布