String Compression :- Wrong answers

This is the question https://hack.codingblocks.com/contests/c/262/107
And this is my code https://ide.codingblocks.com/#/s/24457
I am getting 2 test cases wrong and other 2 as right.

Actually your approach is right, but you have missed something.

For input like “aabbaa”, the output should be “a2b2a2”, but your code gives the output “a4b2”.
Consider this and try to attempt the question again.

1 Like