http://shibaili.blogspot.com/2015/07/google-interview-questions-2.html
abbre word again... follow up是 word->w2d, 另一个wold->wo1d,
也就是说不能group起来,每个都是unique的
返回所有可能的abbreviation
abbre word again... follow up是 word->w2d, 另一个wold->wo1d,
也就是说不能group起来,每个都是unique的
返回所有可能的abbreviation
vector<string> allAbbre(string s) { vector<string> rt; if (s.length() == 0) return rt; if (s.length() < 3) { rt.push_back(s); return rt; } for (int i = 0; i < s.length() - 1; i++) { string prefix = s.substr(0,i + 1); for (int j = s.length() - 1; j > i + 1; j--) { string suffix = s.substr(j); rt.push_back(prefix + to_string(j - i - 1) + suffix); } } return rt;}