当前位置:网站首页>[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;
}
};
边栏推荐
- Distributed transaction -- middleware of TCC -- selection / comparison
- 国元证券开户是真的安全可靠吗
- How will the complete NFT platform work in 2022? How about its core functions and online time?
- P3371 [template] single source shortest path (weakened version)
- [complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
- Generic
- Introduction to thread pool
- Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
- Reading notes on how programs run
- The culprit of unrestrained consumption -- Summary
猜你喜欢
What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
What is the future of software testing industry? Listen to the test veterans' answers
Unity elementary case notes of angry birds Siki college 1-6
[NLP] text classification still stays at Bert? Duality is too strong than learning framework
What is the potential of pocket network, which is favored by well-known investors?
On covariance of array and wildcard of generic type
Pytorch learning notes 5: model creation
Analysis on the scale of China's smart health industry and prediction report on the investment trend of the 14th five year plan 2022-2028 Edition
(Introduction to database system | Wang Shan) Chapter V database integrity: Exercises
It is forbidden to splice SQL in code
随机推荐
Gauss elimination method and template code
UTS | causal reasoning random intervention based on Reinforcement Learning
P3371 [template] single source shortest path (weakened version)
Is the account opening of Guoyuan securities really safe and reliable
Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
Global and Chinese markets for coronary artery disease treatment devices 2022-2028: Research Report on technology, participants, trends, market size and share
ITK learning notes (VII) the position of ITK rotation direction remains unchanged
1214 print diamond
AI Challenger 2018 text mining competition related solutions and code summary
Interview script of Software Test Engineer
[2021]NeRF in the Wild: Neural Radiance Fields for Unconstrained Photo Collections
What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
Selenium library 4.5.0 keyword explanation (I)
It is forbidden to splice SQL in code
(Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
Briefly understand the operation mode of developing NFT platform
The FISCO bcos console calls the contract and reports an error does not exist
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
Struct in linked list