# 简单题,直接对输入做一个变换就可以
class Solution {
public:
string change_word_format(string word){
string result = "";
map<char, string> s;
int index = 0;
for(int i=0;i<word.length();i++){
if(s.find(word[i])==s.end()){
s[word[i]]=to_string(index);
index ++;
}
result += s[word[i]];
}
return result;
}
vector<string> findAndReplacePattern(vector<string>& words, string pattern) {
vector<string> converted_words;
for(int i=0;i<words.size();i++)
converted_words.push_back(change_word_format(words[i]));
string converted_pattern = change_word_format(pattern);
vector<string> results;
for(int i=0;i<converted_words.size();i++){
if(converted_pattern==converted_words[i])
results.push_back(words[i]);
}
return results;
}
};