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.
Yes, your code is even faster than mine
Btw I check the performance on jsbench.me, it's a great site
hi, try my mine please, I think I achieved the best speed result
Perfect solution
I like this solution! :D like mine... but mine definetly uglier
shorter not always better 🙂
Yeah I don't think it would time out since n is being divided smaller like tacoslayer said. You are right that there's no need to keep iterating once it has reached the square root of the number,
BUUUUuuuuut, because this algorithm divides n each time it finds a factor, it will usually get cut short before then anyway. It would only iterate all the way through when n has been reduced to a prime number. not really such a problem generally... but there's no reason not to cut it off at the square root since not all prime numbers are small........it'd be the difference for example between iterating 151051 times and iterating only 388 times.
MY EYES!!!
This is a good implementation of the recursive approach. Which is the first thing that comes to mind when interviewing. The problem with this solution, is time complexity which is O(2^n) where n is the length of s. A better approach is to use Dynamic programming. Then the time and space complexity become O(p1p2) where p1 is the length of part1 and p2 the length of p2.
Genius. Mine was 37 lines.
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