classSolution: defuniqueMorseRepresentations(self, words: List[str]) -> int: az = [chr(x) for x in range(ord('a'), ord('z') + 1)] morse = [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."] mapping = {} for i in range(len(morse)): mapping[az[i]] = morse[i]
result = set() for word in words: temp = '' for ch in word: temp = temp + mapping[ch] result.add(temp)