1
class Solution {
2
public:
3
bool isAlienSorted(vector<string> &words, string order) {
4
unordered_map<char, char> m;
5
for (int i = 0; i < 26; i++) {
6
m[order[i]] = i + 'a';
7
}
8
for (auto &w : words) {
9
for (auto &ch : w) {
10
ch = m[ch];
11
}
12
}
13
return is_sorted(words.begin(), words.end()); // check sorting
14
}
15
};
16
// if you like the solution plz upvote;

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0