当前位置:网站首页>leetcode 53. Maximum Subarray 最大子数组和(中等)
leetcode 53. Maximum Subarray 最大子数组和(中等)
2022-07-06 21:44:00 【InfoQ】
一、题目大意
- 1 <= nums.length <= 105
- -104 <= nums[i] <= 104
二、解题思路
三、解题方法
3.1 Java实现
public class Solution {
public int maxSubArray(int[] nums) {
int n = nums.length;
int[] dp = new int[n];
dp[0] = nums[0];
int max = dp[0];
for (int i = 1; i < n; i++) {
dp[i] = Math.max(dp[i - 1] + nums[i], nums[i]);
max = Math.max(dp[i], max);
}
return max;
}
}
四、总结小记
- 2022/7/6 程序员是不是也有“文人相轻”的毛病
边栏推荐
猜你喜欢

CUDA Programming

Continuous learning of Robotics (Automation) - 2022-

Some thoughts on cross end development of kbone and applet

The most complete deployment of mongodb in history

Food Chem|深度学习根据成分声明准确预测食品类别和营养成分

buildroot的根文件系统提示“depmod:applt not found”

Create commonly used shortcut icons at the top of the ad interface (menu bar)

Mysql-数据丢失,分析binlog日志文件

Tflite model transformation and quantification

Quick completion guide of manipulator (10): accessible workspace
随机推荐
easyui出口excel无法下载框弹出的办法来解决
Some thoughts on cross end development of kbone and applet
使用Thread类和Runnable接口实现多线程的区别
Dab-detr: dynamic anchor boxes are better queries for Detr translation
Redis源码学习(31),字典学习,dict.c(一)
[system management] clear the icon cache of deleted programs in the taskbar
一些常用软件相关
Operational amplifier application summary 1
See Gardenia minor
SSM+JSP实现企业管理系统(OA管理系统源码+数据库+文档+PPT)
二进制、八进制、十六进制
Kbone与小程序跨端开发的一些思考
史上最全MongoDB之初识篇
UltraEdit-32 warm prompt: right association, cancel bak file [easy to understand]
How to manage the expiration of enterprise distribution certificates- How to manage Enterprise Distribution certificate expiration?
leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
List interview common questions
Learn how to use js to merge two objects into one object assign()
Class constant pool and runtime constant pool
What is CGI, IIS, and VPS "suggested collection"