1983. Widest Pair of Indices With Equal Range Sum

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1983

class Solution:
    def widestPairOfIndices(self, nums1: List[int], nums2: List[int]) -> int:
        d = {0: -1}
        res = s = 0
        for i, (a, b) in enumerate(zip(nums1, nums2)):
            s += a - b
            if s in d:
                res = max(res, i - d[s])
            else:
                d[s] = i
        return res