ACBALL - Editorial

I just tried with your code in the practice section by adding a space…

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

Using strlen() repeatedly wastes sometime…

In Java concatenating String takes more time as each time it creates a new instance of String. You can use StringBuilder in Java for concatenation the string or print each character.

There is a gap of 0.00s and 1.01s

First of all, why are you taking so small string? The maximum length will be 10^5, so you should take at least 1 greater than the maximum possible length.

The second point is, your code will not work. In the case when a[i]!=b[i] the output should be B, but in your code, it will give W.

It is actually not 1.01s…it is >=1.01s…that means, the system has stopped the code after 1.01s because the code is taking more than 1s to give the output.

the string has to be lexicographcally smallest
hence the output!