Redian新闻
>
有一帖子说prevailing wage还在处理,求真实性
avatar
有一帖子说prevailing wage还在处理,求真实性# EB23 - 劳工卡
B*1
1
careercup上面看到的,g得phone interiview
Suppose you are given a dictionary of words based on an alphabet with a
fixed number of characters. Please write a method / function which will find
the longest word in the dictionary such that it can be built from
successively adding a single character to an existing word in the dictionary
(in any location). For instance, "a" -> "at" -> "cat" -> "chat" -> "chart".
avatar
t*s
3
介个是trie?

find
dictionary
".

【在 B*******1 的大作中提到】
: careercup上面看到的,g得phone interiview
: Suppose you are given a dictionary of words based on an alphabet with a
: fixed number of characters. Please write a method / function which will find
: the longest word in the dictionary such that it can be built from
: successively adding a single character to an existing word in the dictionary
: (in any location). For instance, "a" -> "at" -> "cat" -> "chat" -> "chart".

avatar
d*d
5
trie 里面找最深节点,path上每个点都是个词。

【在 B*******1 的大作中提到】
: careercup上面看到的,g得phone interiview
: Suppose you are given a dictionary of words based on an alphabet with a
: fixed number of characters. Please write a method / function which will find
: the longest word in the dictionary such that it can be built from
: successively adding a single character to an existing word in the dictionary
: (in any location). For instance, "a" -> "at" -> "cat" -> "chat" -> "chart".

avatar
m*e
6
同顶。我们公司的律师目前以不能做PWD为由把我的case hold 了。
avatar
v*k
7
不行吧,at->cat不在一条path上

【在 d*******d 的大作中提到】
: trie 里面找最深节点,path上每个点都是个词。
avatar
d*d
8
哦,我题目没看仔细。
那就用hashset.

【在 v*****k 的大作中提到】
: 不行吧,at->cat不在一条path上
avatar
b*y
9
有向图,从原点(一个字母开始)找最长的path?

find
dictionary
".

【在 B*******1 的大作中提到】
: careercup上面看到的,g得phone interiview
: Suppose you are given a dictionary of words based on an alphabet with a
: fixed number of characters. Please write a method / function which will find
: the longest word in the dictionary such that it can be built from
: successively adding a single character to an existing word in the dictionary
: (in any location). For instance, "a" -> "at" -> "cat" -> "chat" -> "chart".

avatar
B*1
10
我也是这么想的,建立一个图 ,但是觉得不是最优的。
avatar
g*y
11
1. 把字典按字长分进数组
2. 单字 -> map[1](key, "")
3. 从 i = 2 开始循环,找长度为 i, 减去一个字母后在map[i-1]的keySet里的单词,
放进map[i](key, shrinked)
4. 重复3,直到map[i]为空。
从map[i-1]任挑一个就是最长的可变化的词。英语里好象就一个解: carrousel.
carrousel - carousel - carouse - arouse - rouse - ruse - use - us - s
用本更大的字典找的:
complecting - completing - competing - compting - comping - coping - oping - ping - pig - pi - i
avatar
a*2
12
谁能给个字典文件,想测试一下,多谢
avatar
r*n
13
http://www.mediafire.com/?djzgrn1eong
找到了如下chain:
abranchiate -- 无鳃动物
abranchiate-branchiate-branchiae-branchia-branchi-branch-ranch-rach-ach-ah-h
全是些诡异单词 不知道这是个啥dic。。。
和gloomyturkey的结果一样 这个chain长11
avatar
g*i
14
你的方法是从短的到长的.
从长到短效率相比之下如何? 对一个长词,如果发现最后不能分解,那么一路上所有的变
种都可以不在考虑了

- ping - pig - pi - i

【在 g**********y 的大作中提到】
: 1. 把字典按字长分进数组
: 2. 单字 -> map[1](key, "")
: 3. 从 i = 2 开始循环,找长度为 i, 减去一个字母后在map[i-1]的keySet里的单词,
: 放进map[i](key, shrinked)
: 4. 重复3,直到map[i]为空。
: 从map[i-1]任挑一个就是最长的可变化的词。英语里好象就一个解: carrousel.
: carrousel - carousel - carouse - arouse - rouse - ruse - use - us - s
: 用本更大的字典找的:
: complecting - completing - competing - compting - comping - coping - oping - ping - pig - pi - i

avatar
m*q
15
考个古。火鸡的思路很不错,保证了每次在寻找长度为i+1词的时候,
长度为i的有效词都已经计算出来了,只需要查找这些有效词,类似
于DP。
我觉得从长到短会有很多的重复计算,当然也可以用记事本的方法
不过空间开销比较大

【在 g*****i 的大作中提到】
: 你的方法是从短的到长的.
: 从长到短效率相比之下如何? 对一个长词,如果发现最后不能分解,那么一路上所有的变
: 种都可以不在考虑了
:
: - ping - pig - pi - i

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。