i dont know where my code is wrong as all test cases are not getting correct
my code is-
#include
#include
using namespace std;
int main() {
string s;
cin>>s;
int i,freq[26]={0};
for(i=0;i<s.length();i++)
{
freq[s[i]-‘a’]++;
}
for(i=0;i<26;i++)
{
if(freq[i]==0)
{
continue;
}
else
{
char ch=char(i)+‘a’;
cout<<ch<<freq[i];
}
}
return 0;
}
2 test cases wrong
hey @pragyachoudhary1111, what if the case is aaabbccdsa, here output should be a3b2c2d1s1a1 ur code will give a4b2c2d1s1