Two pointers are 98% faster
\nclass Solution:\n    def maxDistance(self, nums1: List[int], nums2: List[int]) -> int:\n        i = maxdist = 0\n        n = len(nums1)\n        for j, number
```\nclass Solution:\n    def maxDistance(self, nums1: List[int], nums2: List[int]) -> int:\n        i = maxdist = 0\n        n = len(nums1)\n        for j, number2 in enumerate(nums2):\n            while i < n and nums1[i] > number2:\n                i += 1\n            if i == n:\n                return maxdist\n            maxdist = max(maxdist, j - i)\n        return maxdist\n```\n\n![image](https://assets.leetcode.com/users/images/2c3930ab-06ac-4522-bf25-d24f5afa0d73_1665724206.5680892.png)\n
['Two Pointers', 'Python']