public static int maxProduct(int[] A) {
    	if(A == null || A.length ==0) {
    		return 0;
    	}
    	
    	int max = A[0];
    	int prevMax = A[0];
    	int prevMin = A[0];
    	
    	for(int i = 1; i < A.length; i++) {
    		int curtMax = Math.max(A[i], Math.max(prevMin * A[i], prevMax * A[i]));
    		prevMin = Math.min(A[i], Math.min(prevMax * A[i], prevMin * A[i]));

    		prevMax = curtMax;
    		max = Math.max(max, curtMax);
    	}
    	return max;
    }