0

Time Limit exceeded

I feel like I did something terribly wrong, but I have no idea what. Every time I run the code it gives the first output then just says Time Limit Exceeded. https://code.sololearn.com/csv7EJxUe83Q/#cpp

3rd Feb 2017, 2:25 PM
roflcow2
2 odpowiedzi
+ 4
1) Inside mainMenu(), you wrote a while loop which cannot be used in Sololearn as Sololearn doesn't allow taking inputs at runtime. 2) The condition (inputOne!="yes")||(inputOne!="y")||(inputOne!="no")||(inputOne!="n") returns true for every input. If you want it to work, replace it with (inputOne!="yes")&&(inputOne!="y")&&(inputOne!="no")&&(inputOne!="n") so that it returns false for invalid inputs. 3) Inside main(), you are calling mainMenu() multiple times. Instead of that, call it once and put it's value in a string and use it.
3rd Feb 2017, 3:02 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
It's no doubt that sololearn sets time limitation on code playground, in order to prevent infinite loop or other code that will cost a lot of server resource.(If not, they gonna pay a high price for this. ) You can try your code on your own PC. Compile and run, then check if there is any mistake in your code. I hope this will help you. :D
3rd Feb 2017, 3:03 PM
zhenxi
zhenxi - avatar