International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:


	'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 array of strings words where each word can be written as a concatenation of the Morse code of each letter.


	For example, "cab" can be written as "-.-..--...", which is the concatenation of "-.-.", ".-", and "-...". We will call such a concatenation the transformation of a word.


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

&nbsp;
Example 1:

Input: words = ["gin","zen","gig","msg"]
Output: 2
Explanation: The transformation of each word is:
"gin" -&gt; "--...-."
"zen" -&gt; "--...-."
"gig" -&gt; "--...--."
"msg" -&gt; "--...--."
There are 2 different transformations: "--...-." and "--...--.".


Example 2:

Input: words = ["a"]
Output: 1


&nbsp;
Constraints:


	1 &lt;= words.length &lt;= 100
	1 &lt;= words[i].length &lt;= 12
	words[i] consists of lowercase English letters.


class Solution:
	def uniqueMorseRepresentations(self, words: List[str]) -> int:
		code = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..","--","-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."]
		out = []
		for word in words:
			res = [code[ord(char)-ord('a')] for char in word]
			out.append("".join(res))
		return len(set(out))
class Solution {
    public int uniqueMorseRepresentations(String[] words) {
        HashSet<String> set = new HashSet<>();
        String[] morse = new String[]{".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
        
        for (int i = 0; i < words.length; ++i) {
            String temp = "";
            for (int j = 0; j < words[i].length(); ++j) {
                temp += morse[(int)words[i].charAt(j)-'a'];
            }
            set.add(temp);
        }
        return set.size();
    }
}
class Solution {
public:

  string convert(string st)
  {
     string s1[]={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
    string s="";
    for(char a:st)
    {
      s+=s1[a - 'a'];

    }
    return s;

  }
    int uniqueMorseRepresentations(vector<string>& words) {

     set<string>st;
      for(int i=0;i<words.size();i++)
      {
      st.insert(convert(words[i]));

      }

      return st.size();
    }
};
var uniqueMorseRepresentations = function(words) {
    var morse = [".-","-...","-.-.","-..",".","..-.",
                  "--.","....","..",".---",
                  "-.-",".-..","--","-.","---",".--.",
                  "--.-",".-.","...","-","..-","...-",
                  ".--","-..-","-.--","--.."];

    var transformations = new Set();

    for (let word of words) {
        var trans = "";
        for (let letter of word) {
            var index = letter.charCodeAt(0) - 97;
            trans += morse[index];
        }

        transformations.add(trans);
    }

    return transformations.size;
};
Unique Morse Code Words