1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| class Solution { public: int uniqueMorseRepresentations(vector<string>& words) { string code[26]{".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."}; unordered_set<string> set; for(auto& word : words) { string tmp; for(auto ch : word) tmp += code[ch - 'a']; set.emplace(tmp); } return set.size(); } };
|