题解 | #子数组最大乘积#
子数组最大乘积
http://www.nowcoder.com/practice/9c158345c867466293fc413cff570356
public double maxProduct(double[] arr) {
double max = arr[0];
double min = arr[0];
double result = arr[0];
for(int i = 1;i < arr.length; i++){
double m = max, n = min;
max = Math.max(arr[i], Math.max(arr[i] *m , arr[i] * n));
min = Math.min(arr[i], Math.min(arr[i] * m, arr[i] * n));
result = Math.max(result, max);
}
return result;
}
}