当前位置:网站首页>剑指 Offer 10- I. 斐波那契数列
剑指 Offer 10- I. 斐波那契数列
2022-06-25 15:32:00 【anieoo】
solution:
动态规划
class Solution {
public:
int fib(int n) {
if(n < 2) return n;
vector<int> dp(n + 1);
dp[0] = 0;
dp[1] = 1;
for(int i = 2;i <= n;i++) {
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
}
return dp[n];
}
};
边栏推荐
- Internal class learning notes
- Why should the coroutine be set to non blocking IO
- Go closure usage example
- Arthas source code learning-1
- Learning notes on February 18, 2022 (C language)
- [paper notes] overview of case segmentation
- Bessie's weight problem [01 backpack]
- MySQL field truncation principle and source code analysis
- Errno perrno and strerrno
- Architecture evolution of high-performance servers -- Suggestions
猜你喜欢
‘make_ unique’ is not a member of ‘std’
Agent and classloader
Arthas, a sharp tool for online diagnosis - several important commands
剑指 Offer 06. 从尾到头打印链表
Introduction to flexible array
Stack and queue
Learning notes on February 18, 2022 (C language)
[paper notes] poly yolo: higher speed, more precise detection and instance segmentation for yolov3
basic_ String mind map
System Verilog — interface
随机推荐
(1) Introduction
Architecture evolution of high-performance servers -- Suggestions
Is it safe to open a stock account online?
Common operations in VIM
A deformation problem of Hanoi Tower
解决Visio和office365安装兼容问题
Stack and queue
[C language] 32 keyword memory skills
Work of the first week
Leetcode121 timing of buying and selling stocks
Joseph Ring - formula method (recursive formula)
QT animation loading and closing window
QT article outline
1090.Phone List
What is the safest app for stock account opening? Tell me what you know
Pytorch distributed test pit summary
About?: Notes for
Js- get the mouse coordinates and follow them
Is it safe to open a stock account through the account opening link of the account manager?
User defined data type - structure