Using count? It happens to loop for every element in set, through whole list. In case of multiples dictionary or counter should be used, and there is no other optimal way around, just to iterate over list once.
Normally "clearly said..." is not enough, you should know this:-)... Often the first step solving a kata is to check the easiest way and not to find a more difficult solution;-)...
How about checking if each element of arr1 has a square in arr2 and each element has a sqrt in arr1? This is big O of n where as sorting is at best nlogn
Using count? It happens to loop for every element in set, through whole list. In case of multiples dictionary or counter should be used, and there is no other optimal way around, just to iterate over list once.
using .count in set(arr1) and set(arr2) can be quicker, especially when there is a lot of replicate number in long lists.
would not count method run big O of n times?
can you explain why this works?
why is this under dynamic programming?
Normally "clearly said..." is not enough, you should know this:-)... Often the first step solving a kata is to check the easiest way and not to find a more difficult solution;-)...
Clearly said not to use str and still this answer gets the most upvotes. Ironic.
python
ya true. For each element we have to run through the other array.
This comment is hidden because it contains spoiler information about the solution
How about checking if each element of arr1 has a square in arr2 and each element has a sqrt in arr1? This is big O of n where as sorting is at best nlogn
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution