当前位置:网站首页>[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;
}
};边栏推荐
- P3371 [template] single source shortest path (weakened version)
- [PHP basics] cookie basics, application case code and attack and defense
- 2022 Software Test Engineer skill list, please check
- Advanced C language - pointer 2 - knowledge points sorting
- Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
- ISBN number
- 老姜的特点
- Understanding of Radix
- Axure resources and prototype tool Axure RP 9 download
- A method to solve Bert long text matching
猜你喜欢

The FISCO bcos console calls the contract and reports an error does not exist

Report on prospects and future investment recommendations of China's assisted reproductive industry, 2022-2028 Edition

STM32 key light

Reading notes on how programs run

NLP pre training technology development

Eight year test old bird, some suggestions for 1-3 year programmers

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

It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence

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

OS interrupt mechanism and interrupt handler
随机推荐
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
Is the account opening of Guoyuan securities really safe and reliable
system. Exit (0) and system exit(1)
The culprit of unrestrained consumption -- Summary
老姜的特点
Software testers, how can you quickly improve your testing skills? Ten minutes to teach you
A dichotomy of Valentine's Day
不得不会的Oracle数据库知识点(四)
Pytorch learning notes 5: model creation
Entropy and full connection layer
What are the application fields of digital twins in industry?
Unity elementary case notes of angry birds Siki college 1-6
What does redis do? Redis often practices grammar every day
Introducing Software Testing
Solution to the impact of Remote Code Execution Vulnerability of log4j2 component on December 9, 2021
Analysis: misunderstanding of choosing WMS warehouse management system
What is the potential of pocket network, which is favored by well-known investors?
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
Speed up the energy Internet of things. What can low-power Internet of things technology represented by Zeta do?