Let's code in morse.

0

0 votes
Problem

Morse is the language of "."(Dots) and "-"(Dashes) 

  • 'a' maps to ".-",
  • 'b' maps to "-...",
  • 'c' maps to "-.-.", and so on.

For convenience, the full table for the 26 letters of the English alphabet is given below:

[".-","-...","-.-.","-..",".","..-.","....","--..","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--..","-.--"]

Given an Integer N indicating test cases followed by 2N lines first line containing an Integer M size of array and the next line containing array of strings where each word can be written as a concatenation of the Morse code of each letter.

  • For example, "cat" can be written as "['-.-..--']"", which is the concatenation of "-.-.", ".-", and "-". We will call such a concatenation the transformation of a word.

print the number of different transformations among all words we have.

 

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation
Input: words = ["gin","zen","gig","msg"]
Output: 2
Explanation: The transformation of each word is:
"gin" -> "--...-."
"zen" -> "--...-."
"gig" -> "--...--."
"msg" -> "--...--."
There are 2 different transformations: "--...-." and "--...--.".
Editor Image

?