Simple Binary Search Python Solution
Approach: for each i in nums1, let\'s find the last j in nums2 (using binary search with initial limits left=i and right=len(nums2)) that satisfies nums1[i] <= 
Approach: for each **i** in **nums1**, let\'s find the last **j** in **nums2** (using binary search with initial limits **left=i** and **right=len(nums2)**) that satisfies **nums1[i] <= nums2[j]** and then **count the distance (j-i)**. Return the maximum distance.\n\n```\nclass Solution:\n    def maxDistance(self, nums1: List[int], nums2: List[int]) -> int:\n        max_dist = 0\n        for idx, i in enumerate(nums1):\n            l=idx\n            r=len(nums2)\n            while r-l > 1:\n                mid = (l+r)//2\n                if nums2[mid] < i:\n                    r = mid\n                else:\n                    l = mid\n            if l-idx > max_dist:\n                max_dist = l-idx\n        return max_dist\n```\n\n**Thanks! Please, upvote if you find this solution useful.**
['Binary Tree', 'Python']