Unique Morse Code Words
newbie · 190 · lc easy +16 · verified · 83.6% accepted · 2,611 likes · top 95%
Description
International Morse Code assigns each letter a unique sequence of dots and dashes:
- 'a' maps to ".-",
- 'b' maps to "-...",
- 'c' maps to "-.-.", and so on.
The complete mapping for all 26 lowercase English letters is:
[".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
Given an array of strings words, each word can be encoded as the concatenation of its letters' Morse codes.
- For example, "cab" encodes as "-.-..--...", the concatenation of "-.-.", ".-", and "-...". This concatenated result is called the word's transformation.
Return the number of distinct transformations among all words.
Example 1:
Example 2:
Example 3:
Code