public static void printSubmatrix(int[][] input){
        int[][] sum = new int[input.length][input[0].length];
        int maxSum = Integer.MIN_VALUE;
        //copy base case first row and first column as is
        for(int i=0;i<input.length; i++){
            sum[i][0] = input[i][0];
        }
        for(int i=0; i< input[0].length; i++){
            sum[0][i] = input[0][i];
        }

        for(int i =1; i< input.length; i++){
            for(int j=1;j<input[0].length; j++){
                //find minimum of all the three places and increase the size by adding a 1
                if(input[i][j] ==1){
                    sum[i][j] = Math.min(Math.min(sum[i-1][j], sum[i][j-1]), sum[i-1][j-1]) +1;
                    if(sum[i][j] > maxSum){
                        maxSum = sum[i][j];
                    }
                } else {
                    sum[i][j] = 0;
                }

            }
        }

        for(int i=0; i< maxSum; i++){
            for (int j=0; j< maxSum; j++){
                System.out.print(" 1 ");
            }
            System.out.println();
        }

    }