Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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?