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.
Quickselect has O(n**2) in the worst case though. Just iterating over the list and setting the two biggest like in my solution would be optimal in runtime
Because outside of a very narrow set of high performace situations, it doesn't matter at all. Even the cheapest embedded computer can do this in nanoseconds. And treating it like strings is more intuitive since the problem cares about them more like strings than numbers.
This is awesome! My solution is O(n) too but yours is abolutely concise and elegant!
This comment is hidden because it contains spoiler information about the solution
It was written before ..= was stabilized.
This comment is hidden because it contains spoiler information about the solution
The [] case is not needed. foldl just returns initial value if the list is empty