当前位置:网站首页>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 .
边栏推荐
- ARM9开发之学习过程总结[通俗易懂]
- 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?
- 【Hot100】4. Find the median of two positive arrays
- Cross cluster deployment of helm applications using karmada
- 基于DataWorks的时效仿真平台|得物技术
- Batchnorm2d principle, function and explanation of batchnorm2d function parameters in pytorch
- PotPlayer播放百度雲盤視頻
- MetaQ安装部署文档
- 【每日3题(1)】字符串中第二大的数字
- [tcaplusdb knowledge base] view tcapdir directory server
猜你喜欢

MATLB|可视化学习(plot和bar)

PotPlayer播放百度云盘视频

【Hot100】4. Find the median of two positive arrays

You have a chance to collect wool. Click "earn" and you will have a chance to earn a high commission

Cardinality sorting - common sorting method (2/8)
![[golang] how to install iris](/img/c6/842c4e920a74f9a07c2f6a82bb0cc1.png)
[golang] how to install iris

Noip popularization group 2006-2018 preliminary round 2019 csp-j1 2020 csp-j1 improvement program

云上竞技,360°见证速度与激情

浅谈 SAP 软件里的价格折扣设计原理

Introduction to LTSpice circuit simulation
随机推荐
[force button] 35 Search insert location
【208】基于AccessToken方式实现API设计
This simple little function saves 213 hours for our production research team in half a year
How to clear the cache in WordPress
Interview with wangyuntao of China Academy of information technology: digital and real integration enables the prosperity and development of cultural industry
Fs2k face sketch attribute recognition
从入门到精通|Yalmip+Cplex在电力系统中的应用(超棒,看不懂算我输,没有收获也算我输)
PotPlayer播放百度云盘视频
关于接口测试自动化的总结与思考
老司机总结的12条 SQL 优化方案(非常实用)
Cardinality sorting - common sorting method (2/8)
编写自己的 WordPress 模板
Tacacs+服务器部署
使用Karmada实现Helm应用的跨集群部署
[daily 3 questions (2)] maximum ascending subarray sum
A simple reflective XSS operation and idea
【每日3题(2)】最大升序子数组和
如何将你的 WordPress 网站置于维护模式
【TcaplusDB知识库】TcaplusDB限制条件介绍
2019 CSP J2 entry group csp-s2 improvement group round 2 video and question solution