Unique Morse Code Words

PHOTO EMBED

Sat Oct 08 2022 07:41:15 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    int uniqueMorseRepresentations(vector<string>& words) {
        unordered_map<char,string> mp;
        mp['a']=".-";
        mp['b']="-...";
        mp['c']="-.-.";
        mp['d']="-..";
        mp['e']=".";
        mp['f']="..-.";
        mp['g']="--.";
        mp['h']="....";
        mp['i']="..";
        mp['j']=".---";
        mp['k']="-.-";
        mp['l']=".-..";
        mp['m']="--";
        mp['n']="-.";
        mp['o']="---";
        mp['p']=".--.";
        mp['q']="--.-";
        mp['r']=".-.";
        mp['s']="...";
        mp['t']="-";
        mp['u']="..-";
        mp['v']="...-";mp['w']=".--";mp['x']="-..-";mp['y']="-.--";mp['z']="--..";
        set<string> s;
        int n=words.size();
        for(int i=0;i<n;i++)
        {
            int n1=words[i].size();
            string s1="";
            for(int j=0;j<n1;j++)
            {
                s1.append(mp[words[i][j]]);
            }
            s.insert(s1);
            
        }
        return s.size();
        
        
        
    }
};
content_copyCOPY

https://leetcode.com/problems/unique-morse-code-words/