Problem: 1657. 确定两个字符串是否接近-Determine if Two Strings Are Close可以任意两个字符swap所以可以进行冒泡排序考虑到字符类别也可以swap所以不需要考虑特定字符只需要统计字符的频次以及字符的种类对字符的频次单独排序g1, g2对字符的种类单独排序h1, h2只要两者完全相同就可以了需要满足条件(g1 g2) (h1h2)Codeclass Solution { public: bool closeStrings(string word1, string word2) { if( word1.size() ! word2.size() ) return false; int n word1.size(); vectorint t1(26,0), t2(26,0), g1, g2, h1, h2; for(char c : word1) t1[c-a]; for(char c : word2) t2[c-a]; for(int i 0; i 26; i) { if(t1[i] 0) { g1.push_back(t1[i]); h1.push_back(i); } } for(int i 0; i 26; i) { if(t2[i] 0) { g2.push_back(t2[i]); h2.push_back(i); } } sort(g1.begin(), g1.end()); sort(g2.begin(), g2.end()); sort(h1.begin(), h1.end()); sort(h2.begin(), h2.end()); return (g1 g2) (h1h2); } };