1class Solution {2public int uniqueMorseRepresentations(String[] words) {3HashSet<String> set = new HashSet<>();4String[] morse =5new String[] {6".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..",7"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-",8"-.--", "--.."9};1011for (int i = 0; i < words.length; ++i) {12String temp = "";13for (int j = 0; j < words[i].length(); ++j) {14temp += morse[(int) words[i].charAt(j) - 'a'];15}16set.add(temp);17}18return set.size();19}20}