Find the Distance Value Between Two Arrays
Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.
The distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i] - arr2[j]| <= d.
Example 1
Input
arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2Output
2Only 4 and 5 in arr1 have no element in arr2 within distance 2, while 8 is within distance 2 of elements in arr2.
Example 2
Input
arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3Output
2There are 2 elements in arr1 that do not have any element in arr2 within distance 3.
Constraints
- 1 <= arr1.length, arr2.length <= 500
- -1000 <= arr1[i], arr2[j] <= 1000
- 0 <= d <= 100