1 test case going wrong

https://ide.codingblocks.com/s/140492 This is my code

If I input aaaa, your code gives output a * a * a a, but correct output should be a * a * a * a. Or even for aaabb it will give incorrect output. Kindly recheck the code