class Solution {
public:
int uniqueMorseRepresentations(vector<string>& words) {
string label[26] = { ".-","-...","-.-.","-..",".",
"..-.","--.","....","..",".---",
"-.-",".-..","--","-.","---",
".--.","--.-",".-.","...","-",
"..-","...-",".--","-..-","-.--",
"--.." };
size_t m = words.size();
if (m == 0) {
return 0;
}
else {
vector<string> str;
string temp = "";
for (int i = 0; i < m; i++) {
temp = "";
for (int j = 0; j < words[i].size(); j++) {
temp += label[words[i][j] - 'a'];
}
str.push_back(temp);
}
sort(str.begin(), str.end());
int count = 0;
size_t str_size = str.size();
for (int i = 0; i < str_size; i++) {
if (i + 1 < str_size && str[i].compare(str[i + 1]) == 0) {
count++;
}
}
return str_size - count;
}
}
};