Please tell the error in my code, 3rd test case is being failed

here is the link to my code:- https://ide.codingblocks.com/s/654947
plz point out the problem as only one test case is being failed

hi @bhumitkatyal
consider the input aaaaassssddddffaaagggssfffgzx
ur o/p - a8d4f5g4s6xz
expected o/p - a5s4d4f2a3g3s2f3gzx

refer this code -->

hey, i hope it’s clear now?

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.