Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Can anyone give hints on how to get sum by iterating throught the list only once? Passing all tests, but only can find sum num by iterating multiple times. So time-out on large arrays. At a wall and need to be pointed in a direction.
yes, you are right!
0.03 seconds was statistically expected. When I put the correct two elements in the end of the list - it takes much more time.
I'm looking at your code, and there's no way what you're saying is true.
You have a nested loop, which makes the time complexity of your code O(n * n). That means roughly 10 mil * 10 mil iterations. No computer could possibly do this in the time frame you stated.
What you need to do is get your code working by iterating the list only once.
On my 2.3 GHz laptop the calculation for 10 millions random numbers takes only 0.03 seconds in average. But this Kata server says Timeout error.
How is it possible?