Why time limit exceeded? | Sololearn: Learn to code for FREE!
2nd Apr 2017, 4:20 AM
Gopi E
2 Answers
+ 6
a=0 and i=0 at the start and the condition a<=i is true. In every iteration, both variables are incremented meaning the condition is always true thus resulting in an infinite loop. In code playground, there's a limit to the time taken for execution of a program. When it is crossed, execution is stopped and "Time Limit Exceeded" message will be displayed.
2nd Apr 2017, 4:34 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 2
Because when you check the while condition a is always equal to I, since they start equal and you always increment them by the same amount "at the same time".
2nd Apr 2017, 4:23 AM
Luca Garrera