1.subArray问题 通常先转化成前缀和数组,在求解对应问题。 2. two sum a.哈希表的方法:要想明白如何处理数组中两个相同的数相加等于target的情况。 b.掌握two pointers 方法 3.two pointers 应用的问题: two sum及其follow up; so ...
分类:
编程语言 时间:
2016-10-13 21:16:02
阅读次数:
127
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, ...
分类:
其他好文 时间:
2016-10-11 11:08:58
阅读次数:
130
Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return ...
分类:
其他好文 时间:
2016-09-27 14:49:55
阅读次数:
117
感觉和53.maximum subarray有相似处,维护一个localMax,一个globalMax localMax是指左右只选一条的max,简单表示是Math.max(left, right) + nums[i].其实left和right的值因为可能是负数,所以left/right的值是0或者 ...
分类:
其他好文 时间:
2016-09-27 08:05:02
阅读次数:
245
Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return ...
分类:
其他好文 时间:
2016-09-26 06:25:17
阅读次数:
129
public class Solution { public int maxSubArray(int[] nums) { int res = -1000000; int sum=0; for(int i=0; i<nums.length; i++){ sum += nums[i]; if(sum > ...
分类:
其他好文 时间:
2016-09-24 16:12:11
阅读次数:
135
Minimum Size Subarray Sum** Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s ...
分类:
其他好文 时间:
2016-09-23 13:04:54
阅读次数:
119
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, ...
分类:
其他好文 时间:
2016-09-22 06:35:29
阅读次数:
125
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],t ...
分类:
其他好文 时间:
2016-09-22 06:33:15
阅读次数:
193