0
Time limit exceeded......?
Well, I was participating in a coding competition on a website. When I tried to submit my code, I got an error that "time limit exceeded". I was using C++ in my programs, I even tried to change cin, cout to scanf, printf but nothing worked. The code is working perfectly on my device but not on website. Any help?
4 Antworten
+ 2
From what I know, coding competition usually put a time limit for the execution, like 1 second or 2 seconds. It looks like your code is taking a lot of time to be executed and doesn't satisfy the time limit. Your code works fine if there is no time limit
+ 2
Mohit Nagpal
Well usually competition like that relies heavily on using loop, so you can optimize it by making each iteration shorter and more effective, or you can use mathematical calculation to avoid using loops, if possible. There is nothing else in general I can give you, and I cannot give any specific solution since I don't know what the task is
+ 1
Agent_I any idea on what can I do to improve my code?
0
Agent_I ok. Thanks!