We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9abccf commit 6183852Copy full SHA for 6183852
problems/0509.斐波那契数.md
@@ -186,6 +186,26 @@ class Solution {
186
}
187
```
188
189
+```java
190
+//非压缩状态的版本
191
+class Solution {
192
+ public int fib(int n) {
193
+ if (n <= 1) return n;
194
+
195
+ int[] dp = new int[n + 1];
196
197
+ dp[0] = 0;
198
+ dp[1] = 1;
199
200
+ for (int index = 2; index <= n; index++){
201
+ dp[index] = dp[index - 1] + dp[index - 2];
202
+ }
203
204
+ return dp[n];
205
206
+}
207
+```
208
209
Python:
210
```python3
211
class Solution:
0 commit comments