int uniqueMorseRepresentations(vector<string>& words) {
string a[26] = { ".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.." };
set<string>temp;
for (int i = 0; i < words.size(); ++i) {
string str = "";
for (string::iterator p = words[i].begin(); p != words[i].end();++p) {
str += a[*p - 97];
}
temp.insert(str);
}
return temp.size();
}
804 Unique Morse Code Words
猜你喜欢
转载自blog.csdn.net/Leslie5205912/article/details/82019449
今日推荐
周排行