Skip to content

Commit a31bc2f

Browse files
Merge pull request #1660 from CodingTestStudy2/염혜정
[염혜정] Day12
2 parents aa47031 + 57b205d commit a31bc2f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// O(N*W^2)
2+
3+
import java.util.*;
4+
5+
class Solution {
6+
public int minimumLengthEncoding(String[] words) {
7+
Set<String> set = new HashSet<>(Arrays.asList(words));
8+
for (String word : words) {
9+
for (int i = 1; i < word.length(); i++) {
10+
set.remove(word.substring(i));
11+
}
12+
}
13+
int len = 0;
14+
for (String word : set) {
15+
len += word.length() + 1;
16+
}
17+
return len;
18+
}
19+
}

0 commit comments

Comments
 (0)