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.
Hi; the number of lines of code doesn't say anything about the overall time complexity of an algorithm.
For example, if I write
for i in range(10**9971599599): print i
, it will also time out even though it is "only 2 lines".In your case, your algorithm is O(n^2) complexity; and the big test you are failing has approximately
8,000,000
elements in it - therefore you algorithm is performing approximately8000000 ** 2
operations which is very large! You need to find a faster approach (i.e. one that doesn't need to perform so many operations).