题解 | 小红的双生串
小红的双生串
https://www.nowcoder.com/practice/099d6681234d4e3e95c0e0ade31929da
#include <bits/stdc++.h> using namespace std; unordered_map<char,int> mp1,mp2; int ma1 = -1,ma2 = -1; int main() { string str; cin>>str; int len = str.size()>>1; for(int i = 0;i<len;i++){ ma1 = max(ma1,++mp1[str[i]]); } for(int i = len;i<str.size();i++){ ma2 = max(ma2,++mp2[str[i]]); } cout<<2*len-ma1-ma2; return 0; } // 64 位输出请用 printf("%lld")