public boolean exist(char[][] board, String word) {
        if (board == null || word == null || word.length() == 0 || board.length == 0) return false;
        if (board[0].length == 0) return false;
        boolean[][] visited = new boolean[board.length][board[0].length];
        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board[0].length; j++) {
                if (dfs(board, i, j, word, 0, visited)) return true;
            }
        }
        return false;
    }