Hi, so I’ve done the 3rd problem in November challenge just now. I’ve written the code in Java, and it showed me TLE for 2 test cases(Execution Time was shown as 2.1 seconds for both test cases), my friend suggested me to rewrite it in c++, so when I rewrote it in C++ and submitted, all test cases got accepted and the execution time was shown as 0 seconds!!!
I’m not that good at CP, I’m still learning, can someone explain me in detail why this happened ? I’ve been doing CP only in Java, but after seeing this issue, I feel like I’ve made a mistake starting competitive programming with java (or am I wrong in this perspective? ). Should I migrate to C++ ?
Link to the prob - https://www.codechef.com/NOV17/problems/PERPALIN
I’ll update my java code once the november challenge ends, since the contest is still running and I shouldn’t post the solution yet.
Edit:- This is my code - https://www.codechef.com/viewsolution/16248624
Can someone please tell me what exactly is making my code go TLE in java?