如何做一个T9词典的工作?背后是什么数据结构。如果我们输入4663,我们得到'好'的时候,我们preSS向下按钮,我们得到'水涨船高',那么'家'等......
How does a T9 dictionary work? What is the data structure behind it. If we type '4663' we get 'good' when we press down button we get 'gone' then 'home' etc...
编辑:如果46用户类型,那么它应该显示走出去,当pressed向下箭头应该显示走了等......
If the user types in 46 then it should show 'go' and when pressed down arrow should show 'gone' etc...
有可以以多种方式来实现,其中之一是 Trie树。这条路线是重新通过数字psented $ P $和节点指向集合的话。
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.
可以使用嵌套哈希表以及实施,哈希表的关键是一个字母,每数字的算法计算出所有可能的途径(O(3 ^ n)的路由)。
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).
上一篇:面试之谜:跳跃比赛之谜
下一篇:计算剩余时间剩余时间