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.
Building up on the previous comment... Look at: https://wiki.python.org/moin/TimeComplexity
x in list
has O(n) complexity, whilex in set
is O(1) [assuming collisions are unlikely].So, considering
array1
andarray2
have lengthn
andm
, this code usinglist
has complexityO(n * n * m + n * log n)
which can be simplified asO(n**2 * m)
, while usingset
can reduce it toO(n * m + n * log n)
.I know writing this is a great exercise!
But it is already available in the Python standard library (
from fractions import Fraction
)