当前位置:网站首页>[brother hero July training] day 28: dynamic planning
[brother hero July training] day 28: dynamic planning
2022-07-28 21:36:00 【If I were Wen Shuai】
List of articles
One 、53. Maximum subarray and
Give you an array of integers nums , Please find a continuous subarray with the largest sum ( A subarray contains at least one element ), Return to its maximum and .
Subarray Is a continuous part of the array .
leetcode 53 java
Ideas
Dynamic programming dp[i]+=dp[i-1] (dp[i-1]>0)
class Solution {
public int maxSubArray(int[] nums) {
int n = nums.length;
int[] dp = new int[n];
for(int i = 0; i<n ;i++){
dp[i] = nums[i];
if(i>0 && dp[i-1]>0){
dp[i]+=dp[i-1];
}
}
int max = -10010;
for(int i = 0; i<n ;i++){
max = Math.max(max,dp[i]);
}
return max;
}
}
summary
边栏推荐
- 二 RedisTemplate的序列和反序列化机制讲解
- SkiaSharp 之 WPF 自绘 拖曳小球(案例版)
- SSM use @async and create threadpooltaskexecutor thread pool
- ICML2022 | 时序自监督视频transformer
- 【英雄哥七月集训】第 28天:动态规划
- 微服务架构下的系统集成
- Vimtutor编辑
- The Swedish court lifted the 5g spectrum auction ban on Huawei and ZTE
- Timing analysis and constraints based on Xilinx
- Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
猜你喜欢

C语言入门【详细】

Kubedm builds kubernetes cluster

探讨:想要落地DevOps的话,只考虑好的PaaS容器平台就够了么?

职场高薪 |「中高级测试」面试题

CVPR 2022 | 网络中批处理归一化估计偏移的深入研究

Quii Cordova plugin telerik imagepicker plug-in multi image upload out of sequence

LeetCode链表问题——142.环形链表II(一题一文学会链表)

DELTA热金属检测器维修V5G-JC-R1激光测量传感器/检测仪原理分析

工业通讯领域的总线、协议、规范、接口、数据采集与控制系统

Ctfshow question making web module web11~web14
随机推荐
Go concurrent programming basics
面向千元级5G手机市场,联发科天玑700发布
Two excellent software of my love cracking, batch search text, image and video image quality enhancement
多线程顺序运行的 4 种方法,面试随便问
The ref value ‘xxx‘ will likely have changed by the time this effect function runs.If this ref......
Why does Baidu search only crawl, but not show the page?
Buuctf questions upload labs record pass-11~pass-20
酷派主动终止针对小米公司的专利侵权诉讼
移动端空余部位自动填充
在子组件中使用el-date-picker报错
The 35 required questions in MySQL interview are illustrated, which is too easy to understand
30.学习Highcharts 标签旋转柱形图
Maxwell is an easy-to-use software for capturing MySQL data in real time
Vimtutor编辑
Pytorch学习记录(三):随机梯度下降、神经网络与全连接
属性基加密仿真及代码实现(CP-ABE)论文:Ciphertext-Policy Attribute-Based Encryption
Ctfshow network lost track record (1)
1162. Map analysis - non recursive method
编码用这16个命名规则能让你少写一半以上的注释!
1162. 地图分析-非递归法