All test case not passing for this solution?

@Deepanshu_garg hey deepanshu you don’t need to maintain a frequency array either you can do small modification in the code
for(int i=0;i<len;i++){
int count=1;
while(str[i]==str[i+1]&&i<len-1){
i++;
count++;
}
cout<<str[i]<<count;
}

}

Why my code is not passing all the test cases??

@Deepanshu_garg hey Deepanshu let consider this case for better understanding
aaaaba
your output should be a4b1a1 but it giving output as a5b1a5