1 / 3
May 2019

Have you considered the possibility that you might have a coding error that your friend did not?

Or even that you both have the same coding error, for example, accessing an array with an invalid index, but that C++'s lax approach to array bound checking allowed it to pass, whilst Java’s more strict approach did not?

No it is the exact same code. “Copy of my code” . I just told my friend to verify my code. He told me he did the same code in C++ and got accepted. I think the stack memory assigned to java is less. That is why it is giving error. Codeforces and Codechef have proper defined stack size for java. But unfortunately spoj doesn’t care about it😢. By default the stack size is less in java. But spoj hasn’t increased it I guess.