String Compression

#include
#include
using namespace std;
void string_compression(string str)
{
int count[1000]={0};
for(int i=0;i<str.size();i++)
{
count[str[i]]++;
}
for(int i=0;i<str.size();i=i+count[str[i]])
{
cout<<str[i]<<""<<count[str[i]];
}

}
int main() {
string str;
cin>>str;
string_compression(str);
return 0;
}
My code works fine for all the cases but still I get 50 points only
Why??
Whats the error?

NO your code only pass 2 testcase out of 4
hence you got 50 marks
image

For input
aaabbaa
Your Output
a5a5
but correct output
a3b2a5

Now try to do some modification in your code

if you are not able to solve i will help
feel free to ask doubt

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.