Redian新闻
>
请问地下雨水排水管重铺设到哪里找人啊?
avatar
请问地下雨水排水管重铺设到哪里找人啊?# Living
p*p
1
Given N sentences containing lower case letters only, remove all common
phrases from each sentence. A common phrase is defined as three or more
consecutive words that appears in all sentences.
For example,
S1 = "q a b c d"
S2 = "a b c d e"
The only common phrase is "a b c d", so the sentences become:
S1 = "q"
S2 = "e"
You may assume N ≤ 100, and each sentence could contain millions of words.
没什么好的想法,大拿们讲讲思路?
avatar
l*a
2
☆─────────────────────────────────────☆
nasamst (nasa) 于 (Wed Jan 6 19:27:08 2010, 美东) 提到:
mainly for baby food. RT. tks.
☆─────────────────────────────────────☆
alexc (your name is alex) 于 (Wed Jan 6 19:32:27 2010, 美东) 提到:
I registered on Gerber Web site and got formula and baby food coupons. I
have five $1 baby food coupons that expired on 12/31, if you want them. Not
sure if they will still be accepted by stores.

☆─────────────────────────────────────☆
nasamst (nasa) 于 (Wed J
avatar
h*e
3
昨天给一个下班后干私活的plumber打电话,他说做不了。
其实要光是重铺管子我自己就可以干,但是不知为什么,
有坡的地方铺的不是管子,而是塑料网格在上面,下面是个洞,水从下面过,后半截才
是黑粗管,估计里面堵了。
而且在管子和马路中间草地上有一个埋在地下的碗底大小的圆铁开关,不知是干什么用
的。
有没有自己干的,给讲讲吧。
如果请人,应该找什么样的公司啊,关键词搜什么。估计要上小型挖土机。
先谢谢啊!
avatar
p*2
4

有overlap怎么办?

【在 p*****p 的大作中提到】
: Given N sentences containing lower case letters only, remove all common
: phrases from each sentence. A common phrase is defined as three or more
: consecutive words that appears in all sentences.
: For example,
: S1 = "q a b c d"
: S2 = "a b c d e"
: The only common phrase is "a b c d", so the sentences become:
: S1 = "q"
: S2 = "e"
: You may assume N ≤ 100, and each sentence could contain millions of words.

avatar
p*p
5
按出题者意思好像是都删掉,例如
S1 = "q a b c d e"
S2 = "a b c a b c d e"
则S1 = "q"
S2 = ""
不知你说的是不是这种

【在 p*****2 的大作中提到】
:
: 有overlap怎么办?

avatar
p*2
6

how about?
xabcdefca
yabca

【在 p*****p 的大作中提到】
: 按出题者意思好像是都删掉,例如
: S1 = "q a b c d e"
: S2 = "a b c a b c d e"
: 则S1 = "q"
: S2 = ""
: 不知你说的是不是这种

avatar
p*p
7
3个或以上连续的字母算phrase,这样的话应该是
xdefca
ya
如果原来是
xabcadefbca
yabca
则应该是
xdef
y

【在 p*****2 的大作中提到】
:
: how about?
: xabcdefca
: yabca

avatar
c*t
9
You may assume N ≤ 100, and each sentence could contain millions of words.
有这样大数据的话,DP和变种suffix tree都不行吧。我看只能先两个sentences brute
force 求出 all common phrases, 再用结果去其他sentences里面找,得出all
common phrases, 再回来对每个sentences查找删除。

【在 p*****p 的大作中提到】
: 题出处:
: http://discuss.leetcode.com/questions/965/remove-common-phrases

avatar
m*i
10
新手问一下,这里面试可以是用现成的function 吗,还是每一行都要自己码? 比如
PHP
$S1 = "q a b c d";
$S2 = "a b c d e";
$list1 = array_unique(explode(' ',$S1));
$list2 = array_unique(explode(' ',$S2));
$work_list1= $list1;
$work_list2= $list2;
for($i=0;$iif (($key =array_search($list2[$i],$work_list1)) !==false) {
unset($work_list1[$key]);
}
}
for($i=0;$iif (($key =array_search($list1[$i],$work_list2)) !==false) {
unset($work_list2[$key]);
}
}
print_r($work_list1);
print_r($work_list2);
结果也是q 和e
谢谢指正。
avatar
p*2
11

how about?
xabcdefcad
yabcad

【在 p*****p 的大作中提到】
: 3个或以上连续的字母算phrase,这样的话应该是
: xdefca
: ya
: 如果原来是
: xabcadefbca
: yabca
: 则应该是
: xdef
: y

avatar
s*n
12
it should be a map-reduce problem
map: emit all 3-letter or above patterns. hash it--> to a server
reduce-> join for for all N.
in the results, do merge for 4 to ....
note a 4-letters patterns must be composed of two 3-letters pattern.

【在 p*****p 的大作中提到】
: Given N sentences containing lower case letters only, remove all common
: phrases from each sentence. A common phrase is defined as three or more
: consecutive words that appears in all sentences.
: For example,
: S1 = "q a b c d"
: S2 = "a b c d e"
: The only common phrase is "a b c d", so the sentences become:
: S1 = "q"
: S2 = "e"
: You may assume N ≤ 100, and each sentence could contain millions of words.

avatar
c*u
13
这样可以么
用N个hashmap存储每个句子的字母和序号
用第一个hashmap的挨个key value和其他map比较

【在 p*****p 的大作中提到】
: Given N sentences containing lower case letters only, remove all common
: phrases from each sentence. A common phrase is defined as three or more
: consecutive words that appears in all sentences.
: For example,
: S1 = "q a b c d"
: S2 = "a b c d e"
: The only common phrase is "a b c d", so the sentences become:
: S1 = "q"
: S2 = "e"
: You may assume N ≤ 100, and each sentence could contain millions of words.

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