当前位置:网站首页>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
边栏推荐
- 如何编写一个程序猿另一个面试官眼前一亮的简历[通俗易懂]
- kivy教程之设置窗体大小和背景(教程含源码)
- Five years of automated testing, and finally into the ByteDance, the annual salary of 30W is not out of reach
- idea gradle lombok 报错集锦
- C#使用西门子S7 协议读写PLC DB块
- 【系统管理】清理任务栏的已删除程序的图标缓存
- Different meat customers joined hands with Dexter to launch different hamburgers in some stores across the country
- Ggplot facet detail adjustment summary
- One of oscp tools: dirsearch usage Encyclopedia
- [OA] excel document generator: openpyxl module
猜你喜欢
C#使用西门子S7 协议读写PLC DB块
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
Video fusion cloud platform easycvr video Plaza left column list style optimization
Redis configuration and optimization of NoSQL
EasyCVR集群版本添加RTSP设备提示服务器ID错误,该如何解决?
Win11玩绝地求生(PUBG)崩溃怎么办?Win11玩绝地求生崩溃解决方法
【系统管理】清理任务栏的已删除程序的图标缓存
Antd comment recursive loop comment
Analysis on urban transportation ideas of 2022 Zhongqing cup C
Quick completion guide of manipulator (10): accessible workspace
随机推荐
Restore backup data on GCS with tidb lightning
Pyqt5 out of focus monitoring no operation timer
【OA】Excel 文档生成器: Openpyxl 模块
ABAP Dynamic Inner table Group cycle
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
easyui出口excel无法下载框弹出的办法来解决
接口自动化测试实践指导(中):接口测试场景有哪些
[leetcode]Spiral Matrix II
Win11控制面板快捷键 Win11打开控制面板的多种方法
使用Thread类和Runnable接口实现多线程的区别
Learn how to use js to merge two objects into one object assign()
什么是 CGI,什么是 IIS,什么是VPS「建议收藏」
The most complete security certification of mongodb in history
leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
Unity3d can change colors and display samples in a building GL material
[coded font series] opendyslexic font
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
NFT meta universe chain diversified ecosystem development case
【ArcGIS教程】专题图制作-人口密度分布图——人口密度分析
史上最全MongoDB之部署篇