当前位置:网站首页>[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;
}
};边栏推荐
- NLP Chinese corpus project: large scale Chinese natural language processing corpus
- Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
- It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
- Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
- The super fully automated test learning materials sorted out after a long talk with a Tencent eight year old test all night! (full of dry goods
- 不得不会的Oracle数据库知识点(三)
- The difference between fetchtype lazy and eagle in JPA
- What is the GPM scheduler for go?
- [GNN] hard core! This paper combs the classical graph network model
- CSP window
猜你喜欢

Analysis: misunderstanding of choosing WMS warehouse management system
![[PHP basics] session basic knowledge, application case code and attack and defense](/img/f5/713d7044a693ef23e3fbb1ff9bc9f4.jpg)
[PHP basics] session basic knowledge, application case code and attack and defense

手机异步发送短信验证码解决方案-Celery+redis

Sorry, Tencent I also refused

Introducing Software Testing

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

A dichotomy of Valentine's Day

What is the future of software testing industry? Listen to the test veterans' answers

Correlation analysis summary

Eight year test old bird, some suggestions for 1-3 year programmers
随机推荐
不得不会的Oracle数据库知识点(二)
Beijing invites reporters and media
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
Arc 135 supplementary report
Development and application of fcitx functional plug-ins
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
Stock price forecast
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
Is the securities account opened by Caicai for individuals safe? Is there a routine
STM32 key light
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
Unity elementary case notes of angry birds Siki college 1-6
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
What is the difference between NFT, SFT and dnft? How to build NFT platform applications?
Regular expression of shell script value
Generic
Distributed transaction -- middleware of TCC -- selection / comparison
12. Go implementation of integer to Roman numeral and leetcode
On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
Detailed explanation of the relationship between Zhongtai, wechat and DDD