problem
953. Verifying an Alien Dictionary
solution:
class Solution {
public:
bool isAlienSorted(vector<string>& words, string order) {
unordered_map<char, int> alien_order;
for(int i=; i<order.size(); i++)
{
alien_order[order[i]-'a'] = i;
}
for(auto &word:words)
{
for(auto &ch:word)
{
ch = alien_order[ch-'a'];
}
}
return is_sorted(words.begin(), words.end()); }
};
参考
1. Leetcode_easy_953. Verifying an Alien Dictionary;
2. dicuss;
完