当前位置:网站首页>[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;
}
};
边栏推荐
- What are the application fields of digital twins in industry?
- [complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
- ISBN number
- Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
- 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
- Selenium library 4.5.0 keyword explanation (III)
- Detailed explanation of the relationship between Zhongtai, wechat and DDD
- Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
- (Introduction to database system | Wang Shan) Chapter V database integrity: Exercises
- Introduction to thread pool
猜你喜欢
On covariance of array and wildcard of generic type
Eight year test old bird, some suggestions for 1-3 year programmers
Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
Regular expressions and text processors for shell programming
The difference between objects and objects
[GNN] hard core! This paper combs the classical graph network model
Unity elementary case notes of angry birds Siki college 1-6
What is the potential of pocket network, which is favored by well-known investors?
What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
随机推荐
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
Joint examination of six provinces 2017
The FISCO bcos console calls the contract and reports an error does not exist
Docking Alipay process [pay in person, QR code Payment]
What is the GPM scheduler for go?
NLP pre training technology development
不得不会的Oracle数据库知识点(四)
Global and Chinese market of underwater bags 2022-2028: Research Report on technology, participants, trends, market size and share
[PHP basics] session basic knowledge, application case code and attack and defense
Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
Pytorch learning notes 5: model creation
Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
On covariance of array and wildcard of generic type
P1656 bombing Railway
What is the difference between NFT, SFT and dnft? How to build NFT platform applications?
system. Exit (0) and system exit(1)
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
2022 Software Test Engineer skill list, please check
[about text classification trick] things you don't know
Recommendation of knowledge base management system