This commit is contained in:
2023-02-08 12:20:07 +08:00
parent ff53de285f
commit 59242266b3
3 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
#include "s0509_fibonacci_number.hpp"
int S0509::fib(int n) {
vector<int> dp{0, 1};
for (int i{2}; i <= n; ++i) {
dp.push_back(dp[i - 1] + dp[i - 2]);
}
return dp[n];
}