here`s my code in c. It`s giving me a wrong answer. could u explain why?

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

The error is, that you are declaring char array of length 100 only. If S=100, then theres no space for ‘\0’ character, and this causes you to get WA since your loop condition depends on it.

1 Like