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.
Thanks for this brilliant kata
You're right - this solution has O(N) complexity but there is O(1) solution. In fact looks like the current set of tests doesn't allow such a solution to be passed.
It was a wonderful math puzzle. Thank you
Thanks for this nice kata! Enjoyed solving it.
This first
if
condition is not needed here. Ifarr1
is empty,arr1.size()
returns 0 and the secondif
condition is never executed. Ifarr2
is empty, for each statement is not executed andoutArray
is returned as an empty collection anyway.again example 1:
97 isn't a member of the source array, primary 59 is
What a masterpiece! Thanks, docgunthrop.
Really clever
The complexity of this solution is quadratic
In the worst case scenario (the required item is the last one in the array) it will be quadratic complexity
This is a real masterpiece, one of the best 8 kyu katas. My respect to the author
I don't agree with the commenters below. Usually I spend a lot of time trying to reveal the purpose of a task - but this wasn't the case here. The description and examples (especially the one with "CODEWARS" string) are good written and make the task pretty easy to grasp. Nice kata and good job, @DarkD1!
You call
countPrimeDiv
twice on each iteration loop. It can be avoided and calculated only once.Wonderful kata. Got a lot of fun solving it, thanks.
What a wonderful kata! It was a pleasure to solve it, thanks!
Loading more items...