String compression problem code issue

// 2 testcase is not getting pass

#include
using namespace std;
int main() {

char s[101];
cin >> s;
int hash[26]={0};
for(int i=0;s[i]!='\0';i++) {
    hash[s[i]-'a']++;
}
for(int i=0;i<26;i++) {
    if(hash[i]>0) {
        cout<<(char)(i+'a')<<hash[i];
    }
}


return 0;

}
strong text

@code_dynamo hey ashish your code is not giving the right output for the test case like this
abbbbbaaa
your code output is a4b5
but output should be a1b5a3