Given a dictionary of English words, preprocess it in a setup phase so future lookups can be very efficient.
Given 9 letters, where each occurrence can be used at most once and duplicate letters are allowed, find the longest dictionary word that can be formed from those letters.
这道题的核心是先对词典做预处理,把单词按字符频次或字母集合组织起来,方便后续快速判断某个给定字母表能否拼出某个单词。查询时需要考虑每个字母最多使用一次,并且允许重复字母,因此通常会用计数数组、哈希表或位掩码来比较字母频次;如果要找最长单词,可以在所有可行词中维护长度最大的那个。若有多组查询,预处理 Trie、按长度排序再筛选,或者为每个单词保存频次数组,都会显著提升效率。