It can be implemented in several ways, one of them is Trie. The route is represented by the digits and the nodes point to collection of words.
It can be implemented using nested hash tables as well, the key of the hash table is a letter and on every digit the algorithm calculates all possible routes (O(3^n) routes).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…