1
2
3
4
5
6
7
8
9
10
11
12
13
14
| from bisect import bisect_right
class Solution:
def countPairs(self, nums1: List[int], nums2: List[int]) -> int:
res = 0
for i in range(len(nums1)):
nums1[i] -= nums2[i]
nums1.sort()
for i in range(len(nums1)):
res += len(nums1) - bisect_right(nums1, -nums1[i], i + 1)
return res
|