public boolean exist(char[][] board, String word) {
        for (int i = 0; i < word.length(); ++i) {
            set.add(word.substring(0, i + 1));
        }
        for (int i = 0; i < board.length; ++i) {
            for (int j = 0; j < board[0].length; ++j) {
                if (board[i][j] == word.charAt(0)) {
                    if (dfs(board, "", i, j, new boolean[board.length][board[0].length], word))
                        return true;
                }
            }
        }
        return false;
    }