当前位置:网站首页>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
边栏推荐
- 【OA】Excel 文档生成器: Openpyxl 模块
- 别样肉客联手德克士在全国部分门店推出别样汉堡
- [team learning] [34 issues] scratch (Level 2)
- golang 根据生日计算星座和属相
- Redis源码学习(31),字典学习,dict.c(一)
- The most complete deployment of mongodb in history
- Restore backup data on GCS with br
- Restore backup data on GCS with tidb lightning
- See Gardenia minor
- 【ArcGIS教程】专题图制作-人口密度分布图——人口密度分析
猜你喜欢

【OA】Excel 文档生成器: Openpyxl 模块

MySQL data loss, analyze binlog log file

Practice Guide for interface automation testing (middle): what are the interface testing scenarios

Do you choose pandas or SQL for the top 1 of data analysis in your mind?

2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析

Five years of automated testing, and finally into the ByteDance, the annual salary of 30W is not out of reach

Simple implementation of AVL tree insertion and verification operations
![[multi threading exercise] write a multi threading example of the producer consumer model.](/img/8a/4a2836f905968f42e0ef339d900b19.jpg)
[multi threading exercise] write a multi threading example of the producer consumer model.

opencv第三方库

ABAP Dynamic Inner table Group cycle
随机推荐
Analysis on the thinking of college mathematical modeling competition and curriculum education of the 2022a question of the China Youth Cup
[team learning] [34 issues] scratch (Level 2)
使用 BR 恢复 GCS 上的备份数据
UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]
The most complete learning rate adjustment strategy in history LR_ scheduler
Kotlin compose text supports two colors
Some thoughts on cross end development of kbone and applet
学习使用js把两个对象合并成一个对象的方法Object.assign()
VM virtual machine operating system not found and NTLDR is missing
如何编写一个程序猿另一个面试官眼前一亮的简历[通俗易懂]
用头像模仿天狗食月
Golang calculates constellations and signs based on birthdays
The most complete deployment of mongodb in history
Triple half circle progress bar, you can use it directly
Restore backup data on GCS with tidb lightning
Allow public connections to local Ruby on Rails Development Server
Practice Guide for interface automation testing (middle): what are the interface testing scenarios
英特尔David Tuhy:英特尔傲腾技术成功的原因
Implementation of binary search tree
Food Chem|深度学习根据成分声明准确预测食品类别和营养成分