当前位置:网站首页>[dynamic programming] leetcode 53: maximum subarray sum
[dynamic programming] leetcode 53: maximum subarray sum
2022-07-04 00:34:00 【muse_ age】


initialization : dp[0]=nums[0];
Code :
class Solution {
public:
int dp[100001];
int maxSubArray(vector<int>& nums) {
dp[0]=nums[0];
for(int i=1;i<nums.size();i++){
dp[i]=max(dp[i-1]+nums[i],nums[i]);
}
int res=dp[0];
for(int i=0;i<nums.size();i++)
res=max(dp[i],res);
return res;
}
};边栏推荐
- Analysis: misunderstanding of choosing WMS warehouse management system
- Detailed explanation of the relationship between Zhongtai, wechat and DDD
- 12. Go implementation of integer to Roman numeral and leetcode
- 【leetcode】374. Guess the size of the number
- [2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
- Idea a method for starting multiple instances of a service
- [complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
- Recommendation of knowledge base management system
- Gauss elimination method and template code
- Selenium library 4.5.0 keyword explanation (III)
猜你喜欢
![[GNN] hard core! This paper combs the classical graph network model](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[GNN] hard core! This paper combs the classical graph network model

A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
![[cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept](/img/b4/961b3b44e9ecbfd4bddd04318b663a.jpg)
[cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept
![[CSDN Q & A] experience and suggestions](/img/db/dff3173dda24ca5740729b54a81153.jpg)
[CSDN Q & A] experience and suggestions

STM32 GPIO CSDN creative punch in
![Several ways to set up a blog locally [attach relevant software download links]](/img/2f/51a09d9ef71065319ed90306517854.jpg)
Several ways to set up a blog locally [attach relevant software download links]

A method to solve Bert long text matching

Vscode regular match replace console log(.*)

Eight year test old bird, some suggestions for 1-3 year programmers

On covariance of array and wildcard of generic type
随机推荐
Optimization of for loop
I would like to ask how the top ten securities firms open accounts? Is it safe to open an account online?
Pytest unit test framework: simple and easy to use parameterization and multiple operation modes
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
No qualifying bean of type ‘com. netflix. discovery. AbstractDiscoveryClientOptionalArgs<?>‘ available
Advanced C language - pointer 2 - knowledge points sorting
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
Is the securities account opened by Caicai for individuals safe? Is there a routine
MySQL is installed as a Windows Service
不得不会的Oracle数据库知识点(二)
Global and Chinese markets for instant saliva testing devices 2022-2028: Research Report on technology, participants, trends, market size and share
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
Gauss elimination method and template code
国元证券开户是真的安全可靠吗
BBS forum recommendation
2022 system integration project management engineer examination knowledge points: software development model
Anomalies seen during the interview
1214 print diamond
Subgraph isomorphism -subgraph isomorphism