2036. Count Pairs in Two Arrays

Medium
Array
Two Pointers
Binary Search
Sorting

Description

Hints

Hint 1
We can write it as nums1[i] - nums2[i] > nums2[j] - nums1[j] instead of nums1[i] + nums1[j] > nums2[i] + nums2[j].
Hint 2
Store nums1[idx] - nums2[idx] in a data structure.
Hint 3
Store nums2[idx] - nums1[idx] in a different data structure.
Hint 4
For each integer in the first data structure, count the number of the strictly smaller integers in the second data structure with a larger index in the original array.

Statistics

Acceptance
60.4%
Submissions
19,865
Accepted
11,991