src/main/java/com/thiyagu_7/adventofcode/year2021/day20/SolutionDay20.java
private char[][] copyAndExpand(char[][] image, char infiniteSpaceValue) {
        int n = image.length;
        int m = image[0].length;
        char[][] expandedImage = new char[n + 2][m + 2];
        //first row
        for (int j = 0; j <= m + 1; j++) {
            expandedImage[0][j] = infiniteSpaceValue;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                expandedImage[i + 1][j + 1] = image[i][j];
            }
            expandedImage[i + 1][0] = infiniteSpaceValue;
            expandedImage[i + 1][m + 1] = infiniteSpaceValue;
        }
        //last row
        for (int j = 0; j <= m + 1; j++) {
            expandedImage[n + 1][j] = infiniteSpaceValue;
        }
        return expandedImage;
    }
//expand by one row and col on all side
expand by one row and col on all side
expand by one row and col on all side
private char[][] copyAndExpand(char[][] image, char infiniteSpaceValue) {
        int n = image.length;
        int m = image[0].length;
        char[][] expandedImage = new char[n + 2][m + 2];
        for (int j = 0; j <= m + 1; j++) {
            expandedImage[0][j] = infiniteSpaceValue;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                expandedImage[i + 1][j + 1] = image[i][j];
            }
            expandedImage[i + 1][0] = infiniteSpaceValue;
            expandedImage[i + 1][m + 1] = infiniteSpaceValue;
        }
        for (int j = 0; j <= m + 1; j++) {
            expandedImage[n + 1][j] = infiniteSpaceValue;
        }
        return expandedImage;
    }
private char [ ] [ ] copyAndExpand ( char [ ] [ ] image , char infiniteSpaceValue ) { int n = image . length ; int m = image [ 0 ] . length ; char [ ] [ ] expandedImage = new char [ n + 2 ] [ m + 2 ] ; for ( int j = 0 ; j <= m + 1 ; j ++ ) { expandedImage [ 0 ] [ j ] = infiniteSpaceValue ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { expandedImage [ i + 1 ] [ j + 1 ] = image [ i ] [ j ] ; } expandedImage [ i + 1 ] [ 0 ] = infiniteSpaceValue ; expandedImage [ i + 1 ] [ m + 1 ] = infiniteSpaceValue ; } for ( int j = 0 ; j <= m + 1 ; j ++ ) { expandedImage [ n + 1 ] [ j ] = infiniteSpaceValue ; } return expandedImage ; }
expand by one row and col on all side
expand by one row and col on all side
//first row //last row