Bisect whenever you can, 99% speed
Runtime: 1048 ms, faster than 99.18% of Python3 online submissions for Maximum Distance Between a Pair of Values.\nMemory Usage: 31.8 MB, less than 89.90% of Py
Runtime: 1048 ms, faster than 99.18% of Python3 online submissions for Maximum Distance Between a Pair of Values.\nMemory Usage: 31.8 MB, less than 89.90% of Python3 online submissions for Maximum Distance Between a Pair of Values.\n```\nfrom bisect import bisect_left\nclass Solution:\n    def maxDistance(self, nums1: List[int], nums2: List[int]) -> int:\n        nums2.reverse()\n        max_dist = 0\n        len1 = len(nums2) - 1\n        for i, n in enumerate(nums1):\n            max_dist = max(max_dist, len1 - bisect_left(nums2, n) - i)\n            if len1 - i <= max_dist:\n                break\n        return max_dist\n```
['Python', 'Python3']