当前位置:网站首页>[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
- On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
- From functional testing to automated testing, how did I successfully transform my salary to 15K +?
- [C language] break and continue in switch statement
- Eight year test old bird, some suggestions for 1-3 year programmers
- 手机异步发送短信验证码解决方案-Celery+redis
- From functools import reduce -- see the use of reduce function from typical examples
- Kubedl hostnetwork: accelerating the efficiency of distributed training communication
- (Introduction to database system | Wang Shan) Chapter V database integrity: Exercises
- Anomalies seen during the interview
猜你喜欢

Pytorch learning notes 5: model creation

What is the potential of pocket network, which is favored by well-known investors?

Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival

What is the Valentine's Day gift given by the operator to the product?

功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。

STM32 GPIO CSDN creative punch in

On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
![[NLP] text classification still stays at Bert? Duality is too strong than learning framework](/img/49/1ff6025bdb0445e5638c1451e0b267.jpg)
[NLP] text classification still stays at Bert? Duality is too strong than learning framework

Joint examination of six provinces 2017

What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
随机推荐
From functools import reduce -- see the use of reduce function from typical examples
Selenium library 4.5.0 keyword explanation (III)
P3371 [template] single source shortest path (weakened version)
It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
How will the complete NFT platform work in 2022? How about its core functions and online time?
不得不会的Oracle数据库知识点(四)
Recommendation of knowledge base management system
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
Joint examination of six provinces 2017
[leetcode] interview question 17.08 Circus tower
8. Go implementation of string conversion integer (ATOI) and leetcode
Regular expressions and text processors for shell programming
Eight year test old bird, some suggestions for 1-3 year programmers
Pair
UTS | causal reasoning random intervention based on Reinforcement Learning
What is the GPM scheduler for go?
Global and Chinese market of breast cancer imaging 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL winter vacation self-study 2022 12 (1)
Development and application of fcitx functional plug-ins
I would like to ask how the top ten securities firms open accounts? Is it safe to open an account online?