public static void maxProduct(int[] input) {

        int lastMax = input[0];
        int lastMin = input[0];
        int lastMaxStart = 0;
        int lastMinStart = 0;

        int maxProduct = Integer.MIN_VALUE;
        int maxLeft = 0;
        int maxRight = 0;

        for(int i = 1; i< input.length; i++) {

            int currentMax = Math.max(lastMax*input[i], Math.max(lastMin*input[i], input[i]));
            int currentMaxStart = lastMaxStart;
            if( currentMax == input[i]) {
                currentMaxStart = i;
            } else if(currentMax == lastMin*input[i]){
                currentMaxStart = lastMinStart;
            }



            int currentMin = Math.min(lastMax*input[i], Math.min(lastMin*input[i], input[i]));
            int currentMinStart = lastMinStart;
            if(currentMin == lastMax*input[i]) {
                currentMinStart = lastMaxStart;
            } else if(currentMin == input[i]) {
                currentMinStart = i;
            }



            if(currentMax > maxProduct){
                maxProduct = currentMax;
                maxLeft = currentMaxStart;
                maxRight =  i;
            }
            lastMax = currentMax;
            lastMin = currentMin;

            lastMaxStart = currentMaxStart;
            lastMinStart = currentMinStart;


        }

        System.out.println("Max Product : "+ maxProduct+ " from Left:"+ maxLeft+ " to "+ maxRight);

    }