当前位置:网站首页>[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
边栏推荐
- ABB electromagnetic flowmeter maintenance signal transmitter maintenance 41f/e4 technical parameters
- NTP server time (view server time)
- Maintenance of delta hot metal detector principle analysis of v5g-jc-r1 laser measurement sensor / detector
- LT7911D Type-C/DP转mipi 方案成熟可提供技术支持
- Quii Cordova plugin telerik imagepicker plug-in multi image upload out of sequence
- Learning typescript (II)
- C#流程控制语句
- 顺序表的实现
- The framing efficiency of setpreviewcallbackwithbuffer will become lower
- Coding with these 16 naming rules can save you more than half of your comments!
猜你喜欢

MATLAB从入门到精通 第1章 MATLAB入门

High salary in the workplace | "intermediate and advanced test" interview questions

证券企业基于容器化 PaaS 平台的 DevOps 规划建设 29 个典型问题总结

Timing analysis and constraints based on Xilinx

Api 接口优化的几个技巧

蚂蚁集团境外站点 Seata 实践与探索

Kubeadm搭建kubernetes集群

八、QOS队列调度与报文丢弃

详细讲解C语言12(C语言系列)

Maxwell is an easy-to-use software for capturing MySQL data in real time
随机推荐
学习Typescript(二)
Several skills of API interface optimization
传微软已获得向华为供货许可!华为将迎来全面解禁?
Layout the 6G track in advance! Ziguang zhanrui released the white paper "6G unbounded AI"
Four methods of multi-threaded sequential operation. Ask casually during the interview
Maintenance of delta hot metal detector principle analysis of v5g-jc-r1 laser measurement sensor / detector
The Swedish court lifted the 5g spectrum auction ban on Huawei and ZTE
C语言入门【详细】
实现瀑布流效果
面向千元级5G手机市场,联发科天玑700发布
[英雄星球七月集训LeetCode解题日报] 第28日 动态规划
Ijcai2022 tutorial | dialogue recommendation system
Buuctf questions upload labs record pass-11~pass-20
Pytorch学习记录(三):随机梯度下降、神经网络与全连接
For the next generation chromebook, MediaTek launched new chipsets mt8192 and mt8195
How to measure software architecture
The ref value ‘xxx‘ will likely have changed by the time this effect function runs.If this ref......
Go concurrent programming basics
quii cordova-plugin-telerik-imagepicker插件多图上传乱序
8、 QoS queue scheduling and message discarding