c****g 发帖数: 85 | 1 华丽丽地用了LinkedList, HashSet, TreeMap
Question 20.10 Given two words of equal length that are in a dictionary,
write a method to transform one word into another word by changing only one
letter at a time. The new word you get in each step must be in the
dictionary.
EXAMPLE:
Input: DAMP, LIKE
Output: DAMP->LAMP->LIMP->LIME->LIKE
既然dictionary可以用hashtable检查,而一个word的长度有限,先把变化的各种可能
组合列出来,直接用hashtable检查这些words是否存在于字典里。这样是不是更快,更
直观。 |
|