#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
void solve()
{
string s;
cin >> s;
int n = s.size();
int hash[26] = {0};
for(int i = 0; i < n; ++i)
{
hash[s[i] - 'a']++;
}
int cnt = 1;
int mini = 1e9;
for(int i = 1; i < n; ++i)
{
if(s[i] == s[i-1])
{
cnt++;
}
else
{
mini = min(mini, hash[s[i-1] - 'a'] - cnt);
cnt = 1;
}
}
mini = min(mini, hash[s.back() - 'a'] - cnt);
cout << mini << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--)
solve();
}
whats wrong in this approach ?? I counted the frequencies and now i count the consecutive frequencies of the characters and then compare them with the total frequency of that character to know how many swaps will it need to get all together and have maintained the mini variable that tracks the mini swaps