Binary Search
Intuition\nWe just have to iterate over the first list and find the index of largest number in the second list using binary search.\n\n# Complexity\nm = len(num
# Intuition\nWe just have to iterate over the first list and find the index of largest number in the second list using binary search.\n\n# Complexity\nm = len(nums1)\nn = len(nums2)\n- Time complexity:\nO(m*log(n))\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution:\n    def maxDistance(self, nums1: List[int], nums2: List[int]) -> int:\n        max_d = 0\n        l1, l2 = len(nums1), len(nums2)\n        for i in range(l1):\n            left, right = i, l2 - 1\n            while left <= right:\n                index = (left + right) // 2\n                if nums2[index] >= nums1[i]:\n                    left = index + 1\n                else:\n                    right = index - 1\n            max_d = max(max_d, right - i)\n        return max_d\n```
['Binary Search', 'Python3']