当前位置:网站首页>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;
}
}
边栏推荐
- Construction and maintenance of business websites [15]
- Software No.1
- This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
- MySQL view concept, create view, view, modify view, delete view
- * and & symbols in C language
- Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?
- Discussion on the idea of platform construction
- WebGPU(一):基本概念
- This is the form of the K-line diagram (pithy formula)
- MySQL主从延迟问题怎么解决
猜你喜欢
leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
MATLAB realizes voice signal resampling and normalization, and plays the comparison effect
How to use a product to promote "brand thrill"?
RTL8189FS如何关闭Debug信息
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
Redis有序集合如何使用
matlab 使用 audiorecorder、recordblocking录制声音,play 播放声音,audiowrite 保存声音
Should enterprises choose server free computing?
1222. Password dropping (interval DP, bracket matching)
随机推荐
Logging only errors to the console Set system property ‘log4j2. debug‘ to sh
开发工具创新升级,鲲鹏推进计算产业“竹林”式生长
Implementation principle of city selector component
剑指 Offer II 031. 最近最少使用缓存
* and & symbols in C language
[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing
Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
Ar Augmented Reality applicable scenarios
VARIATIONAL IMAGE COMPRESSION WITH A SCALE HYPERPRIOR文献实验复现
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
Failed to transform file 'xxx' to match attributes
MySQL主从延迟问题怎么解决
mysql列转行函数指的是什么
leetcode373. Find and minimum k-pair numbers (medium)
SQLite 3 of embedded database
剑指 Offer 42. 连续子数组的最大和
Selection of field types for creating tables in MySQL database
D discard the virtual recovery method
Should enterprises choose server free computing?
2022 Q2 - 提升技能的技巧总结