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.
Your solution is quite a bit slower than this one actually ;)
Benchmarking on the same input, this solution provides:
Ops/s: 5,122,611
Yours is:
Ops/s: 740,402
This comment is hidden because it contains spoiler information about the solution
You're absolutely right. The sacrifice would be that you'd need a lookup table for the O(n) solution and thus you would require more memory. The solution here and the O(nlogn) solution use the same amount of memory.
You could solve it without sorting the array thus this problem is solvable in O(n).
the break after a return is redundant, a return end execution and breaks out of the switch.
Yeah, definitely a bit of opinion injection here on how to complete it. I agree with Alexandra, less initial code.
Big O is rarely my goal on here lol
O(n^2) when an O(nlogn) solution exists. However, this is short and simple. Codewars users seem to always prefer brevity over performance.
This comment is hidden because it contains spoiler information about the solution
Damn, I forgot about substr. Well Done!
Bonkers
Thank you!
It matches all whitespace characters like tabs or newlines. It's not better, in fact it's likely slower, but it might be more robust in a real world scenario.
this is longer and more complicated than the original, so how do you think it's better?
Nice edge case addition
Loading more items...