import java.util.TreeSet;
public class Solution {
public int uniqueMorseRepresentations(String[] words) {
String[] code = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
TreeSet<String> set = new TreeSet<>();
for (String word : words) {
StringBuilder res = new StringBuilder();
for (int i = 0; i < word.length(); i++) {
String morz = code[word.charAt(i) - 'a'];
res.append(morz.toString());
}
set.add(res.toString());
}
return set.size();
}
}