1855. Maximum Distance Between a Pair of Values

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1855

class Solution:
    def maxDistance(self, nums1: List[int], nums2: List[int]) -> int:
        m, n = len(nums1), len(nums2)
        res = i = j = 0
        while i < m:
            while j < n and nums1[i] <= nums2[j]:
                j += 1
            res = max(res, j - i - 1)
            i += 1
        return res