当前位置:网站首页>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 程序员是不是也有“文人相轻”的毛病
边栏推荐
- Zero knowledge private application platform aleo (1) what is aleo
- Food Chem|深度学习根据成分声明准确预测食品类别和营养成分
- The JSON format of the international area code of the mobile phone number is obtained with PHP
- Learn how to use js to merge two objects into one object assign()
- In cooperation with the research team of the clinical trial center of the University of Hong Kong and Hong Kong Gangyi hospital, Kexing launched the clinical trial of Omicron specific inactivated vacc
- 数据的存储
- OSCP工具之一: dirsearch用法大全
- Golang compresses and decompresses zip files
- 2022电工杯A题高比例风电电力系统储能运行及配置分析思路
- Restore backup data on GCS with br
猜你喜欢
2022中青杯C题城市交通思路分析
史上最全学习率调整策略lr_scheduler
【刷题记录】2. 两数相加
cuda编程
1.19.11. SQL client, start SQL client, execute SQL query, environment configuration file, restart policy, user-defined functions, constructor parameters
Tflite model transformation and quantification
See Gardenia minor
5年自动化测试,终于进字节跳动了,年薪30w其实也并非触不可及
Five years of automated testing, and finally into the ByteDance, the annual salary of 30W is not out of reach
【编码字体系列】OpenDyslexic字体
随机推荐
Allow public connections to local Ruby on Rails Development Server
[untitled]
使用切面实现记录操作日志
The JSON format of the international area code of the mobile phone number is obtained with PHP
Collection of idea gradle Lombok errors
Tflite model transformation and quantification
DAB-DETR: DYNAMIC ANCHOR BOXES ARE BETTER QUERIES FOR DETR翻译
How do test / development programmers get promoted? From nothing, from thin to thick
Termux set up the computer to connect to the mobile phone. (knock the command quickly), mobile phone termux port 8022
史上最全MongoDB之Mongo Shell使用
中青杯2022A题高校数学建模竞赛与课程教育思路分析
ABAP 動態內錶分組循環
【写给初发论文的人】撰写综述性科技论文常见问题
Opencv third party Library
1.19.11. SQL client, start SQL client, execute SQL query, environment configuration file, restart policy, user-defined functions, constructor parameters
OSCP工具之一: dirsearch用法大全
接口自动化测试实践指导(中):接口测试场景有哪些
Use br to back up tidb cluster to GCS
Some thoughts on cross end development of kbone and applet
ABAP 动态内表分组循环