➜ ~

Playing Hacks and Stuffs!


Project maintained by h4ckyou Hosted on GitHub Pages — Theme by mattgraham

Intersection of Two Arrays

image

We can easily implement python builtins function to solve this:

class Solution:
    def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
        num1 = set(nums1)
        num2 = set(nums2)

        intersect = num1.intersection(num2)
        return list(intersect)

But I will implement Binary Search to solve this

Solve Script: link

My script is quite a bit of an overkill and you can tell that the time it takes is pretty not efficient image

Also I was doing lots of debugging hehe :P