public void solve(final char[][] board) {

        // edge cases
        // if only 1 element, there is nothing we can do (pay attention to the order)
        if (board == null || board.length <= 1 || board[0].length <= 1) {
            return;
        }

        // replace upper and lower edges (O -> #)
        for (int i = 0; i < board[0].length; i++) {
            fill(board, 0, i);
            fill(board, board.length - 1, i);
        }

        // replace left and right edges (O -> #)
        for (int i = 0; i < board.length; i++) {
            fill(board, i, 0);
            fill(board, i, board[0].length - 1);
        }

        // now we cleared all the obstacles, we can start replacing all fields (O -> X; # -> O)
        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board[0].length; j++) {
                if (board[i][j] == 'O') {
                    board[i][j] = 'X';
                } else if (board[i][j] == '#') {
                    board[i][j] = 'O';
                }
            }
        }

    }