#K68062. Unique Morse Code Representations
Unique Morse Code Representations
Unique Morse Code Representations
In this problem, you are given a list of words. Each word is composed of lowercase English letters. Using the provided Morse code mapping, transform each word into a Morse code representation by concatenating the Morse codes for its letters. Your task is to determine the number of unique Morse code representations among all words.
The Morse code mapping for each letter is defined as follows: [ \begin{aligned} 'a' &\to .- \ 'b' &\to -... \ 'c' &\to -.-. \ 'd' &\to -.. \ 'e' &\to . \ 'f' &\to ..-. \ 'g' &\to --. \ 'h' &\to .... \ 'i' &\to .. \ 'j' &\to .--- \ 'k' &\to -.- \ 'l' &\to .-.. \ 'm' &\to -- \ 'n' &\to -. \ 'o' &\to --- \ 'p' &\to .--. \ 'q' &\to --.- \ 'r' &\to .-. \ 's' &\to ... \ 't' &\to - \ 'u' &\to ..- \ 'v' &\to ...- \ 'w' &\to .-- \ 'x' &\to -..- \ 'y' &\to -.-- \ 'z' &\to --.. \end{aligned} ]
For instance, the word "gin" is transformed into "--...-." Likewise, process all input words and count the unique transformed Morse code strings.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer (N) denoting the number of words.\
- The second line contains (N) words separated by spaces.
If (N = 0), it indicates an empty list.
outputFormat
Output a single integer to standard output (stdout) representing the number of unique Morse code representations that can be generated from the input words.## sample
4
gin zen gig msg
2
</p>