当前位置:网站首页>Sword finger offer 10- I. Fibonacci sequence
Sword finger offer 10- I. Fibonacci sequence
2022-06-25 15:36:00 【anieoo】
Original link : The finger of the sword Offer 10- I. Fibonacci sequence

solution:
Dynamic programming
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];
}
};边栏推荐
- About?: Notes for
- A deformation problem of Hanoi Tower
- google_ Breakpad crash detection
- [paper notes] overview of case segmentation
- Efficient pytorch: how to eliminate training bottlenecks
- The robot is playing an old DOS based game
- 国信金太阳靠谱吗?是否合法?开股票账户安全吗?
- Finally, we can figure out whether the binding event in the tag is bracketed or not
- Generation method and usage of coredump
- Core mode and immediate rendering mode of OpenGL
猜你喜欢

剑指 Offer 10- I. 斐波那契数列

Solution of push code failure in idea
![[paper notes] street view change detection with deconvolutional networks](/img/2d/777fd0d85ff4d349516b95923410fd.jpg)
[paper notes] street view change detection with deconvolutional networks

Agent and classloader

If a thread overflows heap memory or stack memory, will other threads continue to work

(2) Relational database

通俗讲跨域

剑指 Offer 06. 从尾到头打印链表

Stack and queue

MySQL field truncation principle and source code analysis
随机推荐
Netlogo learning
Data feature analysis skills - correlation test
QT article outline
Source code analysis of nine routing strategies for distributed task scheduling platform XXL job
Yolov5 Lite: fewer parameters, higher accuracy and faster detection speed
Paddlepaddle paper reproduction course biggan learning experience
Using Visual Studio
Download and installation tutorial of consumer
Efficient pytorch: how to eliminate training bottlenecks
剑指 Offer 09. 用两个栈实现队列
Breakpad usage and DMP analysis
Summary of common methods of ArrayList, LinkedList and vector, and analysis of source code learning
Pytorch | how to save and load pytorch models?
GDB debugging
Lombok common notes
Software packaging and deployment
Getting started with lambda8 new features
Client development (electron) data store
Leetcode121 timing of buying and selling stocks
通俗讲跨域