leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0953.cpp (390B)
0 class Solution {
1 public:
2 bool isAlienSorted(vector<string> &words, string order) {
3 vector<char> um(26);
4 for (int i = 0; i < order.size(); i++)
5 um[order[i] - 'a'] = 'a' + i;
6 for (string &word : words)
7 for_each(word.begin(), word.end(), [&um](char &c) { c = um[c - 'a']; });
8 return is_sorted(words.begin(), words.end());
9 }
10 };