How to tell solution is slow or wrong when time limit exceeds?

Hi ppl, I have a little problem in general and its urgent. For some questions, when time exceeds, how can i tell whether my solutions is slow or its wrong. Is there a way to check that my solution is just slow and not wrong. Otherwise one may try to optimize a solution which is inherently slow. Like one solution can be O(n) and best soln is O(logn). One may not be able to think the best algo while working on a correct but rather slow algo, so one may think the slow solutions is incorrect. So please tell me how can I check whether my solution is correct or not when time limit exceeds.

1 Like

Simple answer to your question is: if you are getting TLE, your program is slow

There is a good reason why “wrong answer” (WA) and “time limit” (TLE) are different results. Imagine that I ask you to calculate something difficult and tell you, that you have 5 minutes to find the result. If you do not have some result in 5 minutes I cannot tell if your result is correct or wrong and it’s the same with problems in speed programming. Why there is time limit? Because you can always try all possibilities to find the result, but this is slow and that’s why we are studying algorithms - we want to find better/quicker algorithms.