File tree 1 file changed +0
-26
lines changed
src/main/java/com/fishercoder/solutions 1 file changed +0
-26
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import java .util .List ;
4
4
5
- /**
6
- * 648. Replace Words
7
-
8
- * In English, we have a concept called root,
9
- * which can be followed by some other words to form another longer word
10
- * - let's call this word successor.
11
- * For example, the root an, followed by other, which can form another word another.
12
- * Now, given a dictionary consisting of many roots and a sentence.
13
- * You need to replace all the successor in the sentence with the root forming it.
14
- * If a successor has many roots can form it, replace it with the root with the shortest length.
15
-
16
- You need to output the sentence after the replacement.
17
-
18
- Example 1:
19
- Input: dict = ["cat", "bat", "rat"]
20
- sentence = "the cattle was rattled by the battery"
21
- Output: "the cat was rat by the bat"
22
-
23
- Note:
24
- The input will only have lower-case letters.
25
- 1 <= dict words number <= 1000
26
- 1 <= sentence words number <= 1000
27
- 1 <= root length <= 100
28
- 1 <= sentence words length <= 1000
29
-
30
- */
31
5
public class _648 {
32
6
public static class Solution1 {
33
7
public String replaceWords (List <String > dict , String sentence ) {
You can’t perform that action at this time.
0 commit comments