当前位置:网站首页>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 程序员是不是也有“文人相轻”的毛病
边栏推荐
- 1.19.11. SQL client, start SQL client, execute SQL query, environment configuration file, restart policy, user-defined functions, constructor parameters
- POJ training plan 2253_ Frogger (shortest /floyd)
- 运算放大器应用汇总1
- [system management] clear the icon cache of deleted programs in the taskbar
- 数据的存储
- [leetcode]Spiral Matrix II
- 用头像模仿天狗食月
- Class常量池与运行时常量池
- pyqt5 失焦 监听无操作 定时器
- 史上最全学习率调整策略lr_scheduler
猜你喜欢
随机推荐
機器人(自動化)課程的持續學習-2022-
超越Postman,新一代国产调试工具Apifox,用起来够优雅
Why does WordPress open so slowly?
Force buckle ----- path sum III
How to detect whether the MySQL code runs deadlock +binlog view
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
Antd comment recursive loop comment
Mongo shell, the most complete mongodb in history
[written to the person who first published the paper] common problems in writing comprehensive scientific and Technological Papers
HW notes (II)
Enter the rough outline of the URL question (continuously updated)
[hcie TAC] question 3
[record of question brushing] 2 Add two numbers
[OA] excel document generator: openpyxl module
Ssm+jsp realizes enterprise management system (OA management system source code + database + document +ppt)
Golang calculates constellations and signs based on birthdays
【自动化经验谈】自动化测试成长之路
The first introduction of the most complete mongodb in history
机械臂速成小指南(十):可达工作空间
Use br to back up tidb cluster to GCS








![[coded font series] opendyslexic font](/img/5e/e1512ffe494b5d0e7d6d6765644126.png)
