This code is throwing 'the time limit exceeded' error, please check the code . | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

This code is throwing 'the time limit exceeded' error, please check the code .

The problem is given in the link below I was expecting the result but a time limit related error is being shown . https://www.hackerrank.com/contests/university-codesprint-3/challenges/erupting-volcanoes https://code.sololearn.com/cvCrpou0p6tv/?ref=app

2nd Oct 2017, 8:01 AM
Ishan
Ishan - avatar
6 Antworten
+ 5
In addition to what has been stated. It looks like you could just set the size of the array based off of n by n instead of using 400 by 400. Then there should be no need to initialize the array to all zeros, but rather just set the actual values. Besides your first nested array has an infinite loop as it is right now. The condition is set to f = 400 instead of f <= 400. Organizing your code better would help you to see these types of mistakes. There are other issues as well, but you should attempt to clean up your code before I'll jump into that.
2nd Oct 2017, 8:53 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
I did not go through your compete code, but one suggestion that may solve your problem is rather than using for loops to initialize your array, better approach would be to use memset method under cstring header. like memset (d,0,sizeof(d));//saves resources and time Hope this helps.
2nd Oct 2017, 8:41 AM
balachandar
balachandar - avatar
+ 2
I don't know about it much, will try it , thanks
2nd Oct 2017, 8:50 AM
Ishan
Ishan - avatar
+ 2
@ChaoticDawg thanks , I am looking again it .
2nd Oct 2017, 9:34 AM
Ishan
Ishan - avatar
+ 2
@ChaoticDawg I set all array to zero so that I do not get any garbage when I need to add values to it .
2nd Oct 2017, 9:41 AM
Ishan
Ishan - avatar