#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 110;
int a[30];
int main() {
int t;
cin >> t;
while(t --)
{
string s;
cin >>s;
int sum = 0;
for(int i = 0; i < s.size(); i ++)
{
a[s[i] - 'a'] ++;
if(a[s[i] - 'a'] == 2)
{
sum += 2;;
a[s[i] - 'a'] = 0;
for( int j = 0 ; j <= 27 ; j++ ) a[j] = 0 ;
}
}
memset(a, 0, sizeof a);
cout << s.size() - sum<< endl;
}
}
求两个相同字母相距最小的,在删去中间的部分,就是最小删去的数目。正确做法居然这么短,太离谱了