Problem · Hash Table
Unique Morse Code Words
Learn this problemProblem statement
Each lowercase English letter maps to the following International Morse code string, in alphabet order from a through z:
[".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]The transformation of a word is the concatenation of the Morse strings for its letters. Given words, return the number of distinct transformations.
Function
uniqueMorseRepresentations(words: String[]) → intExamples
Example 1
words = ["gin","zen","gig","msg"]return = 2gin and zen share one transformation, while gig and msg share another.
Example 2
words = ["a"]return = 1A single word contributes one distinct transformation.
Example 3
words = ["no","on"]return = 2The two letter orders produce different concatenated Morse strings.
Constraints
1 <= words.length <= 100.1 <= words[i].length <= 12.- Every word contains only lowercase English letters.