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.
Nice one
MMMAAANNN's two line solution does l=248 in 1 millisecond but any higher causes maximum recursion error.
My point is that this solution is
O(2^n)
too, so your point is invalid.That is exactly my point initially, not sure why are you arguing.
That's because the random tests are woefully weak: only 20 chars max.
Why not try it yourself? ;-) Like this:
This test obliterates most existing solution easily. If not, increase
l
to100
or something.And your solution fails on this case:
Python can crush with an error using recursion on bigger values. This one would at least work.
My solution has linear time and constant memory complexity (although it may not look pretty as some one-liners on this site). I think it's the best we can do here.
Nope, it's still the same as the recursive ones. It'll still timeout badly for long strings.
Nope, it's still the same as the recursive ones. It'll still timeout badly for long strings.
This should be voted as Best Practice!
I think this solution is better then the ones with all of the recursive functions.
So nice.