码迷,mamicode.com
首页 >  
搜索关键字:subarray    ( 846个结果
leetcode_152题——Maximum Product Subarray(动态规划)
Maximum Product SubarrayTotal Accepted:33022Total Submissions:170218My SubmissionsQuestionSolutionFind the contiguous subarray within an array (contai...
分类:其他好文   时间:2015-07-09 22:38:22    阅读次数:120
152 Maximum Product Subarray
这道题使用dp。 dpMax[i] = max(nums[i], nums[i]*dpMax[i-1], nums[i]*dpMin[i-1])多记录一个 dpMin[i]= min(nums[i], nums[i]*dpMax[i-1], nums[i]*dpMin[i-1])但是空间上不需...
分类:其他好文   时间:2015-07-08 00:27:56    阅读次数:88
leetcode_53题——Maximum Subarray(动态规划)
Maximum SubarrayTotal Accepted:62857Total Submissions:182415My SubmissionsQuestionSolutionFind the contiguous subarray within an array (containing at ...
分类:其他好文   时间:2015-07-07 18:37:57    阅读次数:139
[LeetCode] Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the...
分类:其他好文   时间:2015-07-06 19:44:47    阅读次数:115
面试题31:连续子数组的最大和
题目:输入一个整型数组,数组里有正数也有负数。数组中一个或多个整数组成一个子数组。求所有子数组的和的最大值。要求时间复杂度为O(N)。参见LeetCode-Maximum Subarray。
分类:编程语言   时间:2015-07-05 16:40:36    阅读次数:124
7-4日刷题
Subarray Sum Closest1. 保存,然后对sum[i + 1]排序,然后找出相邻值之间的最小差。2. TreeMap:ceilingEntry返回一个键-值映射关系,它与大于等于给定键的最小键关联Value。floorEntry:返回小于等于给定键的最大键关联Value。 pu...
分类:其他好文   时间:2015-07-05 02:01:32    阅读次数:163
Codeforces#86D Powerful array(分块暴力)
Description An array of positive integers a1,?a2,?...,?an is given. Let us consider its arbitrary subarray al,?al?+?1...,?ar, where 1?≤?l?≤?r?≤?n. For every positive integer s denote by Ks the...
分类:其他好文   时间:2015-07-03 06:57:26    阅读次数:135
【LeetCode】209. Minimum Size Subarray Sum
Minimum Size Subarray SumGiven an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If th...
分类:其他好文   时间:2015-06-30 12:36:26    阅读次数:103
[LeetCode] Minimum Size Subarray Sum
The problem statement has stated that there is both an O(n) and O(nlogn) solution to this problem. Let's see the O(n) solution first (taken from this ...
分类:其他好文   时间:2015-06-25 19:25:39    阅读次数:105
Maximum Product Subarray
最大乘积子序列思想:动态规划+最大最小数组 状态方程:考虑到负数,所以加上一个min。 max[i] = Max(max[i-1]*nums[i],min[i-1]*nums[i],nums[i]); min[i] = Min(max[i-1]*nums[i],min[i-1]*n...
分类:其他好文   时间:2015-06-25 12:03:29    阅读次数:95
846条   上一页 1 ... 59 60 61 62 63 ... 85 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!