当前位置:网站首页>【英雄哥七月集训】第 28天:动态规划
【英雄哥七月集训】第 28天:动态规划
2022-07-28 19:41:00 【如果我是温帅帅】
一、53. 最大子数组和
给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
子数组 是数组中的一个连续部分。
leetcode 53 java
思路
动态规划 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;
}
}
总结
边栏推荐
- source insight 使用快捷键
- SSM-使用@Async和创建ThreadPoolTaskExecutor线程池
- Moco V2: further upgrade of Moco series
- [Zhou Zhou has a prize] cloud native programming challenge "edge container" track invites you to fight!
- Attribute based encryption simulation and code implementation (cp-abe) paper: ciphertext policy attribute based encryption
- 4.2 Virtual Member Functions
- 怎么理解数据网格(Data Mesh)
- Moco V1: the visual field can also be self supervised
- 探讨:想要落地DevOps的话,只考虑好的PaaS容器平台就够了么?
- Young freshmen yearn for more open source | here comes the escape guide from open source to employment!
猜你喜欢

Two excellent software of my love cracking, batch search text, image and video image quality enhancement

什么是 CI/CD? | 实现更快更好的软件交付

Ijcai2022 tutorial | dialogue recommendation system

npm如何切换淘宝源镜像

Moco V2: further upgrade of Moco series

工业通讯领域的总线、协议、规范、接口、数据采集与控制系统
![[cloud native] what is ci/cd| Ci/cd to smooth delivery obstacles](/img/4f/e7806d75cd719e181d8455e4fdc1e7.jpg)
[cloud native] what is ci/cd| Ci/cd to smooth delivery obstacles

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

SharkTeam完成Flow生态NFT市场MatrixMarket的安全审计

SSM use @async and create threadpooltaskexecutor thread pool
随机推荐
程序员最大的浪漫~
Link with Bracket Sequence I(状态基多维dp)
The greatest romance of programmers~
到底为什么不建议使用SELECT * ?
微服务架构下的系统集成
Eureka registers with each other, only showing each other or only showing problems in one
Unity - Fundamentals of 3D mathematics
Introduction to blue team: efficiency tools
【TiDB】txt文档导入数据库,这样做真的很高效
ABB电磁流量计维修信号变送器维修41F/E4技术参数
Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
4.1 various calling methods of member
又一款装机神器
What functions does MySQL have? Don't look everywhere. Just look at this.
Invalid prompt object name in SQL Server
(转)冒泡排序及优化详解
Cloud security core technology
属性基加密仿真及代码实现(CP-ABE)论文:Ciphertext-Policy Attribute-Based Encryption
九鑫智能正式加入openGauss社区
High salary in the workplace | "intermediate and advanced test" interview questions