how to resolve the error of 'TIME LIMIT EXCEEDED' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

how to resolve the error of 'TIME LIMIT EXCEEDED'

C++

25th Dec 2017, 9:30 AM
vikrant
vikrant - avatar
3 Answers
+ 12
You shouldn't expect the virtual environment of the Code Playground to absorb complicated calculations. Perhaps simplify your code a bit.
25th Dec 2017, 9:37 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
Optimize your code so it executes in less time, some loops may have to go or be optimised
25th Dec 2017, 9:46 AM
David Akhihiero
David Akhihiero - avatar
+ 5
The inputs on which your code is run after submission are usually much much larger than the sample inputs. The time thats shown as 1.015 is not the actual run time of your code. It may be more than that but the execution of your code is stopped after the time limit To avoid them, you can start with simple things like in C++ use scanf/printf instead of cin/cout, in Java use BufferedReader/PrintWriter instead of Scanner/System.out. Now if you still get TLE, optimise your algorithm. Follow the constraints and check with the complexity of your solution. Usually normal systems can perform around 107107 calculations in a second. Make sure your code makes at the most that many calculations so that it can run under given time limit.
25th Dec 2017, 9:48 AM
GAWEN STEASY
GAWEN STEASY - avatar