当前位置:网站首页>leetcode 53. Maximum subarray maximum subarray sum (medium)
leetcode 53. Maximum subarray maximum subarray sum (medium)
2022-07-07 04:21:00 【InfoQ】
One 、 The main idea of the topic
- 1 <= nums.length <= 105
- -104 <= nums[i] <= 104
Two 、 Their thinking
3、 ... and 、 How to solve the problem
3.1 Java Realization
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;
}
}
Four 、 Summary notes
- 2022/7/6 Do programmers also have “ scholars scorn each other ” What's wrong with
边栏推荐
- UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]
- 2022 electrician cup question B analysis of emergency materials distribution under 5g network environment
- Operational amplifier application summary 1
- DAB-DETR: DYNAMIC ANCHOR BOXES ARE BETTER QUERIES FOR DETR翻译
- Golang calculates constellations and signs based on birthdays
- Kotlin compose text supports two colors
- Surpassing postman, the new generation of domestic debugging tool apifox is elegant enough to use
- EasyCVR集群版本添加RTSP设备提示服务器ID错误,该如何解决?
- Analysis on urban transportation ideas of 2022 Zhongqing cup C
- Restore backup data on GCS with tidb lightning
猜你喜欢
Some thoughts on cross end development of kbone and applet
[knife-4j quickly build swagger]
[team learning] [34 issues] scratch (Level 2)
EasyCVR视频广场点击播放时,主菜单高亮效果消失问题的修复
【写给初发论文的人】撰写综述性科技论文常见问题
Win11控制面板快捷键 Win11打开控制面板的多种方法
The most complete security certification of mongodb in history
5年自动化测试,终于进字节跳动了,年薪30w其实也并非触不可及
buildroot的根文件系统提示“depmod:applt not found”
[multi threading exercise] write a multi threading example of the producer consumer model.
随机推荐
什么是 CGI,什么是 IIS,什么是VPS「建议收藏」
NanopiNEO使用开发过程记录
主设备号和次设备号均为0
Analysis on urban transportation ideas of 2022 Zhongqing cup C
【系统管理】清理任务栏的已删除程序的图标缓存
Use dumping to back up tidb cluster data to GCS
5年自动化测试,终于进字节跳动了,年薪30w其实也并非触不可及
The most complete security certification of mongodb in history
【自动化经验谈】自动化测试成长之路
POJ training plan 2253_ Frogger (shortest /floyd)
Video fusion cloud platform easycvr video Plaza left column list style optimization
The JSON format of the international area code of the mobile phone number is obtained with PHP
史上最全MongoDB之安全认证
vim —- 自己主动的按钮indent该命令「建议收藏」
Storage of data
PHP 实现根据概率抽奖
Analysis on the thinking of college mathematical modeling competition and curriculum education of the 2022a question of the China Youth Cup
2022中青杯C题城市交通思路分析
中青杯2022A题高校数学建模竞赛与课程教育思路分析
Food Chem|深度学习根据成分声明准确预测食品类别和营养成分