当前位置:网站首页>[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;
}
};
边栏推荐
- 不得不会的Oracle数据库知识点(二)
- Regular expressions and text processors for shell programming
- Suggestions for improving code quality
- Anomalies seen during the interview
- Unity elementary case notes of angry birds Siki college 1-6
- [NLP] text classification still stays at Bert? Duality is too strong than learning framework
- (Introduction to database system | Wang Shan) Chapter V database integrity: Exercises
- Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
- 网上的低佣金链接安全吗?招商证券怎么开户?
- 不得不会的Oracle数据库知识点(三)
猜你喜欢
Regular expression of shell script value
Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
Pytorch learning notes 5: model creation
Test the influence of influent swacth on the electromagnetic coil of quartz meter
Qtcharts notes (V) scatter diagram qscatterseries
Shell script three swordsman sed
It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
Att & CK actual combat series - red team actual combat - V
Detailed explanation of the relationship between Zhongtai, wechat and DDD
A dichotomy of Valentine's Day
随机推荐
UTS | causal reasoning random intervention based on Reinforcement Learning
网上的低佣金链接安全吗?招商证券怎么开户?
Self study software testing. To what extent can you go out and find a job?
Data storage - interview questions
Global and Chinese markets for coronary artery disease treatment devices 2022-2028: Research Report on technology, participants, trends, market size and share
What is the difference between NFT, SFT and dnft? How to build NFT platform applications?
Selenium library 4.5.0 keyword explanation (III)
What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
ISBN number
Docking Alipay process [pay in person, QR code Payment]
手机异步发送短信验证码解决方案-Celery+redis
Understanding of Radix
国元证券开户是真的安全可靠吗
Iclr2022: how does AI recognize "things I haven't seen"?
Advanced C language - pointer 2 - knowledge points sorting
A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
SPI based on firmware library
不得不会的Oracle数据库知识点(三)
Is the low commission link on the internet safe? How to open an account for China Merchants Securities?
URL (data:image/png; Base64, ivborw0k... Use case