class Solution {
public:
bool isAlienSorted(vector<string>& words, string order) {
vector<string> words2 = words;
map<char, int> mp;
int idx = 0;
for(char c: order) {
mp[c] = idx++;
}
sort(words2.begin(), words2.end(), [&mp](const string & a, const string& b) {
for(int i = 0 ; i < a.size(); i++) {
if(i == b.size()) {
break;
}
if(mp[a[i]] == mp[b[i]]) {
continue;
}
return mp[a[i]] < mp[b[i]];
}
return a.size() < b.size();
});
for(int i = 0; i < words2.size(); i++) {
if(words2[i] != words[i]) {
return false;
}
}
return true;
}
};

오늘도 꼴찌야 ㅠㅠ