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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Just a minor optimization upgrade ( even though its still O(n^2)).. you only have to check numbers until n/2 since numbers between n/2 and n can't be divisors of n.
This comment is hidden because it contains spoiler information about the solution
So why do you map the characters in the first string, which can potentially be very big, than doing it on the 2nd one ? It helps with performance in average cases.
str2 will aways be shorter than str1 otherwise the function returns false
e.g
str1 has 1million characters
str2 has 5 characters
str2 can be made out from the first 10 characters of str1
you have just saved a lot of space if you also keep track of when keys in the map reach 0.
Check my solution for how to get max performance for this.
This comment is hidden because it contains spoiler information about the solution
Hey,
I struggled a bit with the math part of this part. Maybe you could explain a couple of things.
The whole Math.atan2(y,x) gives me a headache. What are the potential values of this and on what part of the circle is the 0 ?
what does the conversion (1-Math.atan2(y,x) / Math.PI) * 180 do exactly ? What will be the new range of your angle?
Where does the 18 come from when searching for the slice of the circle the angle falls on ?
Cheers, very clean solution.
This comment is hidden because it contains spoiler information about the solution