public int maxProduct(int[] A) {
        if(A.length == 1) return A[0];
        int currMax = A[0], currMin = A[0], max = A[0];
        for(int i = 1; i < A.length; i++){
            int currMaxCopy = currMax;
            currMax = Math.max(Math.max(A[i], currMax *A[i]), currMin * A[i]);
            currMin = Math.min(Math.min(A[i], currMaxCopy * A[i]), currMin * A[i]);
            max = Math.max(max, currMax);
        }
        return max;
    }