[面试题求教]remove common phrases from each sentence# JobHunting - 待字闺中
h*2
1 楼
请求:
Interview Question – Given a set of Sentences containing lower case letters
only, remove common phrases from each sentence. Here a phrase is defined by
3 or more consecutive words.
E.g:
S1 = "I my bye good";
S2 = "my bye good boy";
common phrase is: "my bye good"
so the two sentence become
S1 = "I";
s2 ="boy";
How about the following input ? S1 = "q a b c d a b c b c d e" S2 = "a b c d
e"
What's the output? Is it ok to the following output? S1 = "q" S2 = ""
Yup, your output is correct. This is because there are three common phrases,
ie: "a b c d", "a b c", and "b c d e".
Interview Question – Given a set of Sentences containing lower case letters
only, remove common phrases from each sentence. Here a phrase is defined by
3 or more consecutive words.
E.g:
S1 = "I my bye good";
S2 = "my bye good boy";
common phrase is: "my bye good"
so the two sentence become
S1 = "I";
s2 ="boy";
How about the following input ? S1 = "q a b c d a b c b c d e" S2 = "a b c d
e"
What's the output? Is it ok to the following output? S1 = "q" S2 = ""
Yup, your output is correct. This is because there are three common phrases,
ie: "a b c d", "a b c", and "b c d e".