Redian新闻
>
打算$900 入手尼康28-70 /F2.8
avatar
打算$900 入手尼康28-70 /F2.8# PhotoGear - 摄影器材
s*t
1
题意:
给一个字典,里面有一堆词。然后给一个词,word,求返回,与word编辑距离<=1的所
有出现在字典里的词。
比如说{cat, fat, mat, at, yes, no}, word="cat"返回{cat, fat, mat, at}
被爆了。求解法
avatar
y*g
2
【 以下文字转载自 shopping 讨论区 】
发信人: yoyogg (小狗yoyo), 信区: shopping
标 题: 哪里有木头小板凳卖?
发信站: BBS 未名空间站 (Wed Mar 10 09:12:46 2010, 美东)
RT
谢谢
avatar
s*u
3
打算$900 入手尼康28-70 /F2.8加一个77mm L37滤光镜。 据说是10/10 的状态,这个
价位不知各位大老,神医,大师们有何见教?
avatar
A*i
4
hashtable就可以
avatar
l*u
5
walmart, 10刀

【在 y****g 的大作中提到】
: 【 以下文字转载自 shopping 讨论区 】
: 发信人: yoyogg (小狗yoyo), 信区: shopping
: 标 题: 哪里有木头小板凳卖?
: 发信站: BBS 未名空间站 (Wed Mar 10 09:12:46 2010, 美东)
: RT
: 谢谢

avatar
j*x
6
10/10。。。
都是鬼扯,小心点就是了。。。
avatar
s*t
7
详细点说说?

【在 A*****i 的大作中提到】
: hashtable就可以
avatar
y*g
8
谢谢, 我找来看看
avatar
s*u
9
当然要小心,谢谢指教。
avatar
s*w
10
两种方法
1. 笨办法:遍历字典(n个词),挨个计算与给定 word 的 edit distance。 O(n)
2. 好点的办法: 生成所有edit distannce为1 的词,查看是否在字典中
假设给定 word 有 k个字母
2a. 挨个删除字母, O(k)
2b. 挨个换字母, O(25*k) = O(k)
2c. 挨个加入字母 O(26*(k+1)) =O(k)

【在 s******t 的大作中提到】
: 题意:
: 给一个字典,里面有一堆词。然后给一个词,word,求返回,与word编辑距离<=1的所
: 有出现在字典里的词。
: 比如说{cat, fat, mat, at, yes, no}, word="cat"返回{cat, fat, mat, at}
: 被爆了。求解法

avatar
T*y
11
toysrus

【在 y****g 的大作中提到】
: 谢谢, 我找来看看
avatar
r*x
12
AF-S?

【在 s*****u 的大作中提到】
: 打算$900 入手尼康28-70 /F2.8加一个77mm L37滤光镜。 据说是10/10 的状态,这个
: 价位不知各位大老,神医,大师们有何见教?

avatar
h*d
13
一个一个,老老实实的比较编辑距离吧
avatar
y*g
14
最便宜的塑料板凳$11.
我觉得我可以自己买木头来钉一个了.
anyway, 谢谢
avatar
b*s
15
翻修过也有可能。可能表面看似很新。
avatar
s*t
16
办法2不错。: )
不过复杂度有问题吧,这样假设删完一个字母以后在字典中查的复杂度是O(1)了。应该
是 O(k*k)?

【在 s*w 的大作中提到】
: 两种方法
: 1. 笨办法:遍历字典(n个词),挨个计算与给定 word 的 edit distance。 O(n)
: 2. 好点的办法: 生成所有edit distannce为1 的词,查看是否在字典中
: 假设给定 word 有 k个字母
: 2a. 挨个删除字母, O(k)
: 2b. 挨个换字母, O(25*k) = O(k)
: 2c. 挨个加入字母 O(26*(k+1)) =O(k)

avatar
p*y
17
marshall, 6.99
avatar
s*u
18
Yes. It's AF-S. Is it too good to be true?
How do you tell it is a refurbished? Look at the screws at the back of the
lens?
avatar
j*y
19
这可以用剪枝来优化吧,
只需要找出 edit distance是 0或者 1的
distance 0: equal
distance 1: 只需要考虑 word.length(), word.length() + 1, word.length() -1
的长度的单词

【在 s******t 的大作中提到】
: 题意:
: 给一个字典,里面有一堆词。然后给一个词,word,求返回,与word编辑距离<=1的所
: 有出现在字典里的词。
: 比如说{cat, fat, mat, at, yes, no}, word="cat"返回{cat, fat, mat, at}
: 被爆了。求解法

avatar
y*g
20
谢谢

【在 p***y 的大作中提到】
: marshall, 6.99
avatar
i*e
21
这个价格谈不上too good to be true 吧

Yes. It's AF-S. Is it too good to be true?
How do you tell it is a refurbished? Look at the screws at the back of the
lens?

【在 s*****u 的大作中提到】
: Yes. It's AF-S. Is it too good to be true?
: How do you tell it is a refurbished? Look at the screws at the back of the
: lens?

avatar
c*a
22
跟leetcode/cc150的某题差不多啊
public static List findDistanceOne(Set dict, String str){
List res = new ArrayList();
for(String s: bfs(str))
if(dict.contains(s)) res.add(s);
return res;
}
public static Set bfs(String s){
Set set = new TreeSet();
set.add(s);
for(int i =0;iset.add(s.substring(0,i)+s.substring(i+1));
for(int i =0;ifor(char j='a';j<='z';j++)
set.add(s.substring(0,i)+j+s.substring(i));
for(int i=0;ifor(char j='a';j<='z';j++){
char[] ch = s.toCharArray();
if(ch[i]!=j){
ch[i]=j;
String nstr = new String(ch);
set.add(nstr);
}
}
}
return set;
}
avatar
l*t
23
micheals这种店也有可能卖的。

【在 y****g 的大作中提到】
: 【 以下文字转载自 shopping 讨论区 】
: 发信人: yoyogg (小狗yoyo), 信区: shopping
: 标 题: 哪里有木头小板凳卖?
: 发信站: BBS 未名空间站 (Wed Mar 10 09:12:46 2010, 美东)
: RT
: 谢谢

avatar
r*x
24
价格正常,看成色吧~~
成色好的话价格还不错

【在 s*****u 的大作中提到】
: Yes. It's AF-S. Is it too good to be true?
: How do you tell it is a refurbished? Look at the screws at the back of the
: lens?

avatar
M*5
25
如果我还记得的话,careercup这题有个前提吧,好象是说所有的word长度都是一样的?

str){

【在 c*****a 的大作中提到】
: 跟leetcode/cc150的某题差不多啊
: public static List findDistanceOne(Set dict, String str){
: List res = new ArrayList();
: for(String s: bfs(str))
: if(dict.contains(s)) res.add(s);
: return res;
: }
: public static Set bfs(String s){
: Set set = new TreeSet();
: set.add(s);

avatar
c*e
26
价钱一般, 而且这头又大又重, 不如直接上24-70, 省得以后再折腾, 呵呵

【在 s*****u 的大作中提到】
: 打算$900 入手尼康28-70 /F2.8加一个77mm L37滤光镜。 据说是10/10 的状态,这个
: 价位不知各位大老,神医,大师们有何见教?

avatar
s*t
27
还记得链接不?求一个

str){

【在 c*****a 的大作中提到】
: 跟leetcode/cc150的某题差不多啊
: public static List findDistanceOne(Set dict, String str){
: List res = new ArrayList();
: for(String s: bfs(str))
: if(dict.contains(s)) res.add(s);
: return res;
: }
: public static Set bfs(String s){
: Set set = new TreeSet();
: set.add(s);

avatar
s*u
28
Thank you all!
avatar
c*a
29
加上length-1的那些substring就行了吧

的?

【在 M********5 的大作中提到】
: 如果我还记得的话,careercup这题有个前提吧,好象是说所有的word长度都是一样的?
:
: str){

avatar
y*n
30
遍历字典中的词
计算长度差:
-1:原词减字对比
0 :两词减字对比
1 :字典词减字对比
最坏情况:O(n*s); n=字典词书, s=词长度

【在 s******t 的大作中提到】
: 题意:
: 给一个字典,里面有一堆词。然后给一个词,word,求返回,与word编辑距离<=1的所
: 有出现在字典里的词。
: 比如说{cat, fat, mat, at, yes, no}, word="cat"返回{cat, fat, mat, at}
: 被爆了。求解法

avatar
l*a
31
时间上很差
空间上不错

【在 y****n 的大作中提到】
: 遍历字典中的词
: 计算长度差:
: -1:原词减字对比
: 0 :两词减字对比
: 1 :字典词减字对比
: 最坏情况:O(n*s); n=字典词书, s=词长度

avatar
l*i
32
each word s in the dictionary is mapped/hashed into multiple keys, where
each key is the word minus one letter, for example, if word is "cat"
then there are 4 entries with value "cat"
key="cat"
key="ca"
key="ct"
key="at"
Now two words have distance of 1 iff they have a common key.
Proof:
1. if two words w1 and w2 have distance of 1, then it is either an insert/
delete/change. All three will have w1 and w2 map into one common key.
2. if two words w1 and w2 have a common key, then that key is either the
word itself or the word remove one letter. It is easily verified that w1 and
w2 have distance at most 1.
Now each word w is mapped into at most |w| keys, where |w| is the number of
letters in w. Since English words are in general short, less than 15 letters
. We use space O(n * max|w|) and all words with distance at most 1 will be
in the same hash table entry. The value of each hashtable entry is a list of
words, and they all have distance at most 1 between each other.
avatar
x*0
33
mark
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。