正文
增加 11 行删除 11 行
24 行未改动25262728293031323310 行未改动44454647484950515253545556575859606162636465666768697071726 行未改动79808182838485868788899091929394959697989910010110210310410524 行未改动- 字符统计: a:1, b:2, c:1- 最多出现: b (2次)- 修改次数 = 4 - 2 = 2- 结果: 把a和c改为b,得到"bbbb"推导第二个xxx- 长度 = 3- 字符统计: x:3- 最多出现: x (3次)10 行未改动int main() {//ios::sync_with_stdio(false);//cin.tie(nullptr);int T;cin >> T;while (T--) {string s;cin >> s;array<int, 26> count{}; //统计26个字母出现的次数int max_count = 0; // 记录最大出现次数for (char c : s) {int idx = c - 'a';count[idx]++;if (count[idx] > max_count) {max_count = count[idx];}}cout << s.length() - max_count << '\n';}return 0;}```6 行未改动int main() {//ios::sync_with_stdio(false);//cin.tie(nullptr);int T;cin >> T;while (T--) {string s;cin >> s;map<char, int> count;int max_count = 0;for (char c : s) {count[c]++;if (count[c] > max_count) {max_count = count[c];}}cout << s.length() - max_count << '\n';}return 0;}```24 行未改动25262728293031323310 行未改动44454647484950515253545556575859606162636465666768697071726 行未改动79808182838485868788899091929394959697989910010110210310410524 行未改动- 字符统计: a:1, b:2, c:1- 最多出现: b (2次)- 修改次数 = 4 - 2 = 2- 结果: 把a和c改为b,得到"bbbb"推导第二个xxx- 长度 = 3- 字符统计: x:3- 最多出现: x (3次)10 行未改动int main() {//ios::sync_with_stdio(false);//cin.tie(nullptr);int T;cin >> T;while (T--) {string s;cin >> s;array<int, 26> count{}; //统计26个字母出现的次数int max_count = 0; // 记录最大出现次数for (char c : s) {int idx = c - 'a';count[idx]++;if (count[idx] > max_count) {max_count = count[idx];}}cout << s.length() - max_count << '\n';}return 0;}```6 行未改动int main() {//ios::sync_with_stdio(false);//cin.tie(nullptr);int T;cin >> T;while (T--) {string s;cin >> s;map<char, int> count;int max_count = 0;for (char c : s) {count[c]++;if (count[c] > max_count) {max_count = count[c];}}cout << s.length() - max_count << '\n';}return 0;}```