当前位置:网站首页>55. maximum sum of continuous subarrays
55. maximum sum of continuous subarrays
2022-06-28 16:59:00 【hys__ handsome】
Record the standard schedule of classic questions .
Ideas
Greedy practices : Add a number first , If it is less than 0 Just directly remake. Because there's no need to put negative numbers first , It would be better to get rid of it .
class Solution {
public:
int maxSubArray(vector<int>& nums) {
int res = -0x3f3f3f3f, sum = 0;
for(int i = 0,tmp = 0; i < nums.size(); i++){
sum += nums[i];
res = max(res,sum);
if(sum < 0) sum = 0;
// If nums All negative numbers return the largest negative number
}
return res;
}
};dp Strategy .
边栏推荐
- 硕士学位论文写作探索学习
- 2022年暑期及9月份CSP-J1 CSP-S1初赛 培训计划及学习要点
- How to install WordPress on a web site
- Noip popularization group 2006-2018 preliminary round 2019 csp-j1 2020 csp-j1 improvement program
- C#/VB. Net to convert PDF to excel
- StackOverflow 2022 开发者报告:PostgreSQL 超越 MySQL !
- Tacacs+服务器部署
- [daily 3 questions (2)] maximum ascending subarray sum
- 使用Karmada实现Helm应用的跨集群部署
- MATLB|电力系统优化运行与市场化
猜你喜欢

StackOverflow 2022 开发者报告:PostgreSQL 超越 MySQL !

Cloud sports, 360 ° witnessing speed and passion

抓取手机端变体组合思路设想

O & M - unified gateway is very necessary

After the first failure, AMEC rushed to the Hong Kong stock exchange for the second time, and the financial principal changed frequently

Csp-j1 csp-s1 preliminary training plan and learning points in summer and September 2022

Practice of curve replacing CEPH in Netease cloud music

"Popular science leaders say" intelligent bionic robot fish

Lucky draw animation - Carp jumps over the dragon's gate

visio 使用
随机推荐
A simple reflective XSS operation and idea
中国SSD行业企业势力全景图
Cross cluster deployment of helm applications using karmada
一步一步教你制作的第一个 WordPress 插件
[random talk] January 31, 2021 Oh Huo
Please ask me, the queries written in my database account for 99%. Is it better to use pay as you go mode or reservation mode?
Noip1998-2018 csp-s2 2019 2021 improvement group problem solving report and video
MetaQ安装部署文档
小新黑苹果声卡ID注入
Tianyi cloud web application firewall (edge cloud version) passed the first batch of trusted authentication
NOIP1998-2018 CSP-S2 2019 2021提高组解题报告与视频
Stm32cubemx usage and function introduction
基于Krack的网络攻击「建议收藏」
【每日3题(1)】字符串中第二大的数字
PotPlayer播放百度云盘视频
【Redis】2021/01/31 Redis的简单归纳 No.01
Batchnorm2d principle, function and explanation of batchnorm2d function parameters in pytorch
[tcapulusdb knowledge base] view the business password
China energy integration and Tianyi cloud create an "energy brain"
Research on master's thesis writing