class Solution {
public:
bool isJudge(string str1,string str2) {
mapm;
for (int i = 0; i < str1.size(); i++) {
m[str1[i]]++;
}
for (int i = 0; i < str2.size(); i++) {
auto temp = m.find(str2[i]);
if (temp != m.end()) m[str2[i]]--;
if (temp == m.end()) return false;//从str2中查到了str1中不存在的字符
}
for (auto mt = m.begin(); mt != m.end(); mt++) {
if (mt->second != 0) return false;
}
return true;
}
vector removeAnagrams(vector& words) {
vectorans;
int i = 0;
for (int j = 1; j < words.size(); j++) {
if (isJudge(words[i],words[j])) {
words[j] = "-1";
} else {
i = j;
}
}
for (int j = 0; j < words.size(); j++) {
if (words[j] != "-1") ans.push_back(words[j]);
}
return ans;
}
};



