Imagine you're a radio operator during World War II, intercepting secret messages transmitted in Morse code! Each letter has its unique pattern of dots and dashes - 'a' becomes ".-", 'b' becomes "-...", and so on.
You've intercepted an array of words, and you need to determine how many unique transformations exist when each word is converted to its complete Morse code representation.
For example, the word "cab" transforms to "-.-..--..." by concatenating:
- 'c' → "-.-."
- 'a' → ".-"
- 'b' → "-..."
Your mission: Count how many different Morse code transformations you can create from all the given words.
The complete Morse code alphabet is: [".-","-...","-.-.","-.."."."."..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
Input & Output
Visualization
Time & Space Complexity
Visit each word once (n), transform each character (m average word length)
Hash set stores at most n unique transformations, each of average length m
Constraints
- 1 ≤ words.length ≤ 100
- 1 ≤ words[i].length ≤ 12
- words[i] consists of lowercase English letters only
- Each letter maps to exactly one Morse code pattern