当前位置:网站首页>[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;
}
};边栏推荐
- The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
- Is the securities account opened by Caicai for individuals safe? Is there a routine
- 手机异步发送短信验证码解决方案-Celery+redis
- What is the GPM scheduler for go?
- Five high-frequency questions were selected from the 200 questions raised by 3000 test engineers
- Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
- Introduction to thread pool
- P1656 bombing Railway
- UTS | causal reasoning random intervention based on Reinforcement Learning
- AI Challenger 2018 text mining competition related solutions and code summary
猜你喜欢

SPI based on firmware library

功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。

Analysis: misunderstanding of choosing WMS warehouse management system

It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something

NLP Chinese corpus project: large scale Chinese natural language processing corpus

A method to solve Bert long text matching

MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query

Regular expression of shell script value

It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
![P3371 [template] single source shortest path (weakened version)](/img/c5/bcb22e1ea573253005e56ebbd73bb7.jpg)
P3371 [template] single source shortest path (weakened version)
随机推荐
What does redis do? Redis often practices grammar every day
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
Anomalies seen during the interview
URL (data:image/png; Base64, ivborw0k... Use case
What is the potential of pocket network, which is favored by well-known investors?
想请教一下,十大劵商如何开户?在线开户是安全么?
Version rollback revert don't reset better reset must be forced
What are the application fields of digital twins in industry?
Shell script three swordsman sed
Global and Chinese markets for blood and liquid heating devices 2022-2028: Research Report on technology, participants, trends, market size and share
Detailed explanation of the relationship between Zhongtai, wechat and DDD
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
Eight year test old bird, some suggestions for 1-3 year programmers
不得不会的Oracle数据库知识点(三)
Similarities and differences of text similarity between Jaccard and cosine
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
BBS forum recommendation
Correlation analysis summary
OS interrupt mechanism and interrupt handler
[CSDN Q & A] experience and suggestions