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
Hey there! Thanks for trying it out! Glad you enjoyed it. Make sure you also check out the next one in the series. Cheers!
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.I couldn't agree less. We don't know if we are allowed to switch containers that we already put on a stack earlier on. Specs are of low quality.
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.Loading more items...