やるだけ
class WordAbbreviation { public: vector <string> getAbbreviations(vector <string> ws) { const int size = ws.size(); vector <string> v(size); while (true) { map<string, int> cnt; for (int i = 0; i < (int)size; ++i) { ++cnt[v[i]]; } cnt.erase(""); if (cnt.size() == size) break; for (int i = 0; i < (int)size; ++i) { if (cnt[v[i]] != 1) v[i] += ws[i][v[i].size()]; } } return v; } };