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.
Choose your flavour ;-) - see above
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
if it works, don't touch it!
damn it, guess I can't get it to run all the tests before timing out. Thanks for checking, I'll have to keep working on it :/
I tried to think about an iterative solution to this, but I couldn't. I guess that's ChatGPT's work to do (it told me to just simulate the recursion in a while loop but I'm too lazy to do it).
now it doesnt pass bruh
I think it's worth mentioning that O(n) and O(2n) are «technically» the same time complexity. Obviously O(2n) is worse than O(n), but in terms of big O notation, they're both linear, so they're the same thing.
and he sacrificed the space complexity!
same thing as drhrich but you avoid subtracting 1 to len(num)-y by passing 1 to enumerate (enumerate has a parameter "start" to start the enumeration at that number)
I have to disagree on that one:
Using the fastest fork of the current most upvoted solution from
@Blind4Basic
, this solution is achieving the same performance on batches of 3000 tests - 570ms in average.You can certainly stop to iterate earlier but linear complexity is the best you can achieve.
Also relying on Python builtins is certainly clearer (and usually faster) than hand-written loop logic.
Anyways, thanks for the compliment ;-)
Sadly, this is slower than other solutions. Other than that, good golfing :p
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...