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;
    }
}