当前位置:网站首页>Sword finger offer 42 Maximum sum of continuous subarrays
Sword finger offer 42 Maximum sum of continuous subarrays
2022-07-02 02:00:00 【Yake1965】
The finger of the sword Offer 42. The maximum sum of successive subarrays
class Solution {
public int maxSubArray(int[] nums) {
int pre = -100, ans = nums[0];
for(int x : nums){
pre = pre < 0 ? x : pre + x; // Start again when sum is negative
if(pre > ans) ans = pre;
}
return ans;
}
}
边栏推荐
- The role of artificial intelligence in network security
- new和malloc的区别
- From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
- Logging only errors to the console Set system property ‘log4j2. debug‘ to sh
- PR second training
- leetcode2305. 公平分发饼干(中等,周赛,状压dp)
- Android: the kotlin language uses grendao3, a cross platform app development framework
- Makefile simple induction
- 【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享
- 【C#】使用正则校验内容
猜你喜欢

Three core problems of concurrent programming

MySQL约束与多表查询实例分析

How to use redis ordered collection

What is AQS and its principle

Feature extraction and detection 16 brisk feature detection and matching

剑指 Offer 62. 圆圈中最后剩下的数字

How to turn off debug information in rtl8189fs

城市选择器组件实现原理

SQLite 3 of embedded database

leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
随机推荐
Construction and maintenance of business websites [10]
1222. Password dropping (interval DP, bracket matching)
OpenCASCADE7.6编译
* and & symbols in C language
Four basic strategies for migrating cloud computing workloads
1217 supermarket coin processor
如何远程、在线调试app?
479. Additive binary tree (interval DP on the tree)
MySQL主从延迟问题怎么解决
正则表达式学习笔记
Matlab uses audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound
剑指 Offer 31. 栈的压入、弹出序列
leetcode2305. 公平分发饼干(中等,周赛,状压dp)
Open那啥的搭建文档
Makefile simple induction
This is the form of the K-line diagram (pithy formula)
What is the MySQL column to row function
Failed to transform file 'xxx' to match attributes
JPM 2021 most popular paper released (with download)
跨域?同源?一次搞懂什么是跨域