当前位置:网站首页>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;
}
}
边栏推荐
- Medical management system (C language course for freshmen)
- Openssl3.0 learning XXI provider encoder
- 剑指 Offer 62. 圆圈中最后剩下的数字
- MySQL主从延迟问题怎么解决
- How to use a product to promote "brand thrill"?
- 1218 square or round
- [deep learning] Infomap face clustering facecluster
- "C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
- Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
- 剑指 Offer 29. 顺时针打印矩阵
猜你喜欢

医药管理系统(大一下C语言课设)

JMeter (II) - install the custom thread groups plug-in

What is the MySQL column to row function

MATLAB realizes voice signal resampling and normalization, and plays the comparison effect

1222. Password dropping (interval DP, bracket matching)

leetcode2312. Selling wood blocks (difficult, weekly race)

matlab 实现语音信号重采样和归一化,并播放比对效果

The role of artificial intelligence in network security

matlab 使用 audioread 、 sound 读取和播放 wav 文件

How to build and use redis environment
随机推荐
Matlab uses audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound
np.where 和 torch.where 用法
开发工具创新升级,鲲鹏推进计算产业“竹林”式生长
What is AQS and its principle
[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology
Volume compression, decompression
SQLite 3 of embedded database
How to build and use redis environment
【LeetCode 43】236. The nearest common ancestor of binary tree
Parted command
[Floyd] post disaster reconstruction
MySQL constraints and multi table query example analysis
new和malloc的区别
1069. Division of convex polygons (thinking, interval DP)
Software No.1
Laravel artisan common commands
leetcode2312. Selling wood blocks (difficult, weekly race)
Construction and maintenance of business websites [14]
matlab 实现语音信号重采样和归一化,并播放比对效果
Electronic Association C language level 1 33, odd even number judgment