International Morse Code maps each letter to a series of dots and dashes: "a" -> ".-", "b" -> "-...", "c" -> "-.-.", and so on. The transformation of a word is the concatenation of the codes of its letters, for example "cab" -> "-.-..--...". Given an array of strings words, return the number of different transformations among all words.
International Morse Code maps each letter to a series of dots and dashes: "a" -> ".-", "b" -> "-...", "c" -> "-.-.", and so on. The transformation of a word is the concatenation of the codes of its letters, for example "cab" -> "-.-..--...". Given an array of strings words, return the number of different transformations among all words.
Example 1:
Input: {"words":["gin","zen","gig","msg"]}
Output: 2
Constraints:
1≤words.length≤100
1≤words[i].length≤12
words[i] consists of lowercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"words":["gin","zen","gig","msg"]}
Each of the 4 words becomes one long string of dots and dashes. Different words can produce the same string, because the letter boundaries disappear once the codes are glued together.