1885. Count Pairs in Two Arrays

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

Содержание

LeetCode problem 1885

class Solution:
    def countPairs(self, nums1: List[int], nums2: List[int]) -> int:
        n = len(nums1)
        d = [nums1[i] - nums2[i] for i in range(n)]
        d.sort()
        return sum(n - bisect_right(d, -v, lo=i + 1) for i, v in enumerate(d))