这题看起来和max subarray差不多,只是加法变乘法,尝试过用分治法,发现划分情况的时候特别麻烦。于是分析下这题本身的特点:1、对0较敏感,一旦有0,乘积就不变了,所以需要在遇到0 的时候将数组拆分2、如果没有0, 一旦相乘,绝对值肯定会变大,所以仅考虑正负号的问题就够了。若整个数组相乘是一个...
分类:
其他好文 时间:
2014-09-30 17:23:59
阅读次数:
206
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...
分类:
其他好文 时间:
2014-09-29 03:53:16
阅读次数:
255
新题。。。不过很简单。。半年才更新一个题。。。class Solution {public: int maxProduct(int arr[], int n) { int pmax = arr[0]; int pmin = arr[0]; int an...
分类:
其他好文 时间:
2014-09-28 13:25:52
阅读次数:
178
[leetcode] Latest added:2014-09-23Find the contiguous subarray within an array (containing at least one number) which has the largest product.For exam...
分类:
编程语言 时间:
2014-09-28 01:51:00
阅读次数:
499
#include#includeusingnamespacestd;intmin(inta,intb){returna>b?b:a;}intmax(inta,intb){returna>b?a:b;}intmaxProduct(intA[],intn){if(n==0){return0;}if(n=...
分类:
其他好文 时间:
2014-09-27 23:27:10
阅读次数:
188
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 contiguous subarray [2,3] has the larges...
分类:
其他好文 时间:
2014-09-26 15:03:38
阅读次数:
359
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 contiguous subarray [2,3] has the larges...
分类:
其他好文 时间:
2014-09-26 01:16:58
阅读次数:
271
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...
分类:
其他好文 时间:
2014-09-25 15:11:49
阅读次数:
209
题目描述: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,...
分类:
编程语言 时间:
2014-09-25 13:26:28
阅读次数:
281
LinkedIn 高频题 – Maximum Sum/ProductSubarrayMaximum Sum Subarray是leetcode原题,跟Gas Station的想法几乎一模一样。解答中用到的结论需要用数学简单地证明一下。123456789101112public int maxSubA...
分类:
其他好文 时间:
2014-09-25 13:16:18
阅读次数:
223