Open prateeekgoel7248 opened 2 years ago
Can you please share the question?
@jha00 is right it depends on question for an example - recursive and overlapping sub problems are modified by memoization ( dynamic programming ) maybe a question requires you a better approach improving complexity is just about making solutions efficient ( btw i suck at this thing i am also a victim of TLE )
Usually in CP, TLE occurs when your code takes more than 5 sec. to run the test-case for Python code and 1sec for C/Cpp (in codeforces - 1sec for Python as well). You need to have a brief understanding of time complexity for this. By calculating the time complexity of an algorithm, it is possible to check, before implementing the algorithm, that it is efficient enough for the problem.
Anyways, I too get the TLE occasionally😅😁
Well, to reduce the complexity of a program you have to use a better algorithm or sometimes an efficient data structure. Before writing the actual code, calculate the complexity and if its within the time constraints of question, then you're good to go otherwise try to find more efficient solution, optimize your code etc.
Hi! I do coding on many platforms and I got TLE(time limit exceed) errors many times so I just want to know how can I reduce the time complexity of my python program.