Create 递归相关.md

master
Omooo 4 years ago
parent 97c1b4a7c9
commit eae7986496
  1. 26
      blogs/Algorithm/剑指 Offer/递归相关.md

@ -0,0 +1,26 @@
---
递归相关
---
#### [10- I. 斐波那契数列](https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/)
```java
class Solution {
public int fib(int n) {
if (n == 0 || n == 1) {
return n;
}
int start = 0;
int end = 1;
int result = 0;
for (int i = 2; i <= n; i++) {
result = (start + end) % 1000000007;
start = end;
end = result;
}
return result;
}
}
```
Loading…
Cancel
Save