+ 4
ahhh....thought.....qsort() first then.........instead of having a second array....if current == next, replace current with a 0 (zero) in the same array then loop through to do the sum. Again, no idea how long it would take. Is removing the duplicates the main objective or are you just trying to get sum of the none duplicates?
24th May 2020, 12:33 AM
rodwynnejones
rodwynnejones - avatar
+ 3
You could use qsort() to sort them, then... in a single loop, check if the current is equal to next......if it isn't...... put the current into second array..(but I have no ideal how long that would take)....then loop through the second array to do the sum. (still thinking about it thought.)
24th May 2020, 12:22 AM
rodwynnejones
rodwynnejones - avatar
+ 2
Runtime exceeded is a Sololearn issue because the runtime for every code here is limited to a few seconds. Did you try the same code on your computer?
23rd May 2020, 11:39 PM
HonFu
HonFu - avatar