One test case failed! pls help

#include<bits/stdc++.h>
using namespace std;

int main() {

char a[1000];
cin>>a;

int freq[26]={0};

for(int i=0;i<strlen(a);i++){
	freq[a[i]-'a']++; 
}

for(int i=0;i<26;i++){
	
	if(freq[i]==1){
		char c='a'+i;
		cout<<c;
	}
	
	else if(freq[i]>1){
		char c='a'+i;
		cout<<c<<freq[i];
	}
}


return 0;

}

hi @anshul3558_e8c9aa486c392ca3
issue is that u r changing the order
abbaaa -> your output is a4b2 but ans is a1b2a2

@anshul3558_e8c9aa486c392ca3 refer here https://ide.codingblocks.com/s/662074

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.