Output incorrect

https://hack.codingblocks.com/app/contests/1975/173/problem
solution : https://ide.codingblocks.com/s/383370

unable to print the commas correctly

Do one thing, print 1 outside while loop, as cout<< ans[idx] outside while loop and then print rest of the remaining string in loop only

Have done it here


have a look

yeah it is finally working now but 1 test case is failing

Might be some logical error. Test for side cases. If it still doesn’t get accepted. Then let me now the test case number.

I tried but couldn’t figure it test case number is 2

it is working now I did one small change

So i marking all your doubts as resolved now. Do give your feedback :slight_smile:

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.