What is wrong with the below code?

https://www.codechef.com/viewsolution/28149513

char[] res = "0000000000".toCharArray();

You initialized your result array outside while loop. Due this next test cases are using result of previous test case as it’s initial array instead of “0000000000” . Just put it inside first while loop.

Also it’s good practice to try code for multiple test cases before submitting. Sometimes we tend to miss global variables.

1 Like

Thanks for finding out the error @nchack.

1 Like