import java.util.HashSet;
import java.util.Set;
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
String[] words = {"gin", "zen", "gig", "msg"};
System.out.println(solution.uniqueMorseRepresentations(words));
}
public int uniqueMorseRepresentations(String[] words) {
Set list = new HashSet<>();
String[] table = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--",
"-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
for (String word : words) {
String str = "";
for (char c : word.toCharArray()) {
str += table[c - 'a'];
}
list.add(str);
}
return list.size();
}
}