1
class Solution {
2
public int uniqueMorseRepresentations(String[] words) {
3
HashSet<String> set = new HashSet<>();
4
String[] morse =
5
new String[] {
6
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..",
7
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-",
8
"-.--", "--.."
9
};
10

11
for (int i = 0; i < words.length; ++i) {
12
String temp = "";
13
for (int j = 0; j < words[i].length(); ++j) {
14
temp += morse[(int) words[i].charAt(j) - 'a'];
15
}
16
set.add(temp);
17
}
18
return set.size();
19
}
20
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0