码迷,mamicode.com
首页 >  
搜索关键字:subarray    ( 846个结果
[LeetCode] 689. Maximum Sum of 3 Non-Overlapping Subarrays 三个非重叠子数组的最大和
In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. Each subarray will be of size k, and we want to max ...
分类:移动开发   时间:2018-09-23 16:37:21    阅读次数:267
leetcode 53-Maximum Subarray(medium)
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. 1. use an arr ...
分类:其他好文   时间:2018-09-23 15:06:24    阅读次数:122
[LeetCode] 152. Maximum Product Subarray 求最大子数组乘积
Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: E ...
分类:编程语言   时间:2018-09-20 11:22:11    阅读次数:162
[LeetCode] 209. Minimum Size Subarray Sum 最短子数组之和
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't ...
分类:编程语言   时间:2018-09-20 11:07:27    阅读次数:166
maximum sum of a subarray with at-least k elements.
// Returns maximum sum of a subarray with at-least // k elements. static int maxSumWithK(int a[], int n, int k) { // maxSum[i] is going to store maxim... ...
分类:其他好文   时间:2018-09-20 11:07:17    阅读次数:178
[LeetCode] Maximum Average Subarray I 子数组的最大平均值
由于这道题子数组的长度k是确定的,所以我们其实没有必要建立整个累加数组,而是先算出前k个数字的和,然后就像维护一个滑动窗口一样,将窗口向右移动一位,即加上一个右边的数字,减去一个左边的数字,就等同于加上右边数字减去左边数字的差值,然后每次更新结果res即可,参见代码如下: ...
分类:编程语言   时间:2018-09-19 21:44:01    阅读次数:191
175.Shortest Unsorted Continuous Subarray(最短未分类连续子阵列)
题目: Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will ...
分类:其他好文   时间:2018-09-18 15:58:48    阅读次数:135
53. Maximum Subarray
一、题目 1、审题 2、分析: 给出一个整形数组(可能全是负数),求连续的子数组的最大的和。 二、解答 1、思路: 方法一、动态规划 令 maxNum 代表最大和,tmpMaxNum 代表临时最大和。 当向后扫描时,对第 j 个元素有两种选择,要么放入前面的子数组,要么作为新数组的第一个元素; 如果 ...
分类:其他好文   时间:2018-09-15 15:22:10    阅读次数:162
maximum-subarray 序列最大连续和 贪心
Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array[?2,1,?3,4,?1,2,1 ...
分类:其他好文   时间:2018-09-14 00:05:17    阅读次数:171
leetcode 697.Degree of an Array
题意是指在数组中取得出现频率最高的数,然后计算数之间的间隔的。 那么这里可以简单的使用map映射关系来求解的,并且统计出现的次数以及对应的位置关系的。 ...
分类:其他好文   时间:2018-09-12 15:57:42    阅读次数:130
846条   上一页 1 ... 22 23 24 25 26 ... 85 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!