当前位置:网站首页>leetcode先刷_Maximum Subarray
leetcode先刷_Maximum Subarray
2022-07-06 11:48:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
dp创始人级精英赛的冠军。最大的部分和。
扫从左至右,保持一个最佳值而当前部分和,在这一部分,并成为负值什么时候。再往下的积累后,也起到了负面作用,所以,放弃直销,然后部分和初始化为阅读的当前位置。
class Solution {
public:
int maxSubArray(int A[], int n) {
int mmax = A[0], tpsum = A[0];
for(int i=1;i<n;i++){
if(tpsum<0) tpsum = A[i];
else tpsum += A[i];
if(tpsum > mmax)
mmax = tpsum;
}
return mmax;
}
};版权声明:本文博客原创文章。博客,未经同意,不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117150.html原文链接:https://javaforall.cn
边栏推荐
- 信息系统项目管理师---第八章 项目质量管理
- Zero foundation entry polardb-x: build a highly available system and link the big data screen
- How to customize animation avatars? These six free online cartoon avatar generators are exciting at a glance!
- 零基础入门PolarDB-X:搭建高可用系统并联动数据大屏
- 深入分析,Android面试真题解析火爆全网
- Use of deg2rad and rad2deg functions in MATLAB
- Looting iii[post sequence traversal and backtracking + dynamic planning]
- 【翻译】供应链安全项目in-toto移至CNCF孵化器
- 深度剖析原理,看完这一篇就够了
- Finally, there is no need to change a line of code! Shardingsphere native driver comes out
猜你喜欢
![[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)](/img/1e/b270a81c8457f1eae34f55c004a01a.png)
[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)

JDBC details
![[translation] micro survey of cloud native observation ability. Prometheus leads the trend, but there are still obstacles to understanding the health of the system](/img/63/3addcecb69dcb769c4736653952f66.png)
[translation] micro survey of cloud native observation ability. Prometheus leads the trend, but there are still obstacles to understanding the health of the system

LeetCode_ Double pointer_ Medium_ 61. rotating linked list

MySQL information schema learning (I) -- general table

接雨水问题解析

冒烟测试怎么做

Documents to be used in IC design process

社招面试心得,2022最新Android高频精选面试题分享

MySQL information Schema Learning (i) - - General table
随机推荐
MySQL information schema learning (II) -- InnoDB table
Classic 100 questions of algorithm interview, the latest career planning of Android programmers
In depth analysis, Android interview real problem analysis is popular all over the network
Unbalance balance (dynamic programming, DP)
Problems encountered in using RT thread component fish
蓝桥杯 微生物增殖 C语言
转让malloc()该功能后,发生了什么事内核?附malloc()和free()实现源
redisson bug分析
[calculating emotion and thought] floor sweeper, typist, information panic and Oppenheimer
Alibaba数据源Druid可视化监控配置
350. 两个数组的交集 II
Simple application of VBA script in Excel
系统性详解Redis操作Hash类型数据(带源码分析及测试结果)
Li Kou 101: symmetric binary tree
从sparse.csc.csr_matrix生成邻接矩阵
Leetcode 30. 串联所有单词的子串
凤凰架构3——事务处理
LeetCode_ Double pointer_ Medium_ 61. rotating linked list
From spark csc. csr_ Matrix generate adjacency matrix
Low CPU load and high loadavg processing method