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.
damn bro
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?
thank you!
I solved it!
A pair are two numbers, not three.
Hello,everyone.
I might have understood the problem right but:
Given test case ([1, 4, 8, 7, 3, 15],8):
The pair whose second element has the smallest index is [1,4,3] not [1,7] because index of 4 is 1 in ints lists compared index of 7 which is 3.
Can anyone help me please?
noice