Skip to content

Commit aa47031

Browse files
Merge pull request #1661 from CodingTestStudy2/강병호
[강병호] Day12
2 parents 007a633 + 28514d2 commit aa47031

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)