Find the maximum number of valid pairs between two arrays.
Unlock detailed company stats for this questionUpgrade
Given two arrays arr1 and arr2 and an integer d, form the maximum number of pairs (arr1[i], arr2[j]) satisfying arr1[i] <= arr2[j] <= arr1[i] + d. Each element can be used in at most one pair. Example: arr1 = [8, 20, 35, 45], arr2 = [25, 50], d = 10 gives 2 pairs: (20, 25) and (45, 50). Constraints: 1 <= arr1.size(), arr2.size() <= 10^5, 1 <= d <= 10^5.
Community answers
No answers contributed by the community yet.
Related questions
Find the maximum number of boy-girl invitation pairs from an m x n grid.Find the maximum product of any two integers in an array.Find the maximum substring sum based on the difference between the number of 0s and the number of 1s.Related courses

Course

Course
Course
