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.
as a russian, i just noticed how weird the singular and plural cases are for days ect lol
ah thank you, such a simple sounding kata, yet its taking me so long haha
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).i only have 3 lines of code, but it keeps failing at that one big number test due to time out, it did the same when i tried it with one line. (i thought something more compact might help but it didnt) :( idk why this keeps happening???
This comment is hidden because it contains spoiler information about the solution
writing this solution felt like cheating for some reason lol
ugh that looks so satisfying, i love to try and make all my code as compact as possible. how did i not think of this?!?