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.
This comment is hidden because it contains spoiler information about the solution
I'm not sure if there's a name for it. I'm using it here because otherwise
int('')
would throw an error, but''
also evaluates to false, so usingor
here lets me coerce''
to0
.You may want to read on the topic of 'Time Complexities' in code (Also search for 'Big O notation'). The tests in this kata are so large that you pretty much need to have an algorithm that is O(n) - which means it looks at each element of the original list only once.
To do even one single
reverse
requires looking at each element once, so if you use it even a couple times, your algorithm is probably too slow.pop()
is nice and fast, but taking elements from the front (pop(0)
) means that all other elements have to be moved up one index, so it is also O(n). There are clever ways around this, but I won't tell you what they are. (Google might be your friend. You are looking for 'constant time operations')