I’d done this question, Can you please see my approach, whether it is good or not??
String compression
i check your code
it is correct and good as well
if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved 
Seri Bhaiya , Thank you so much.