Given two integer arrays arr1 and arr2 and an integer d, return the distance value: the number of elements arr1[i] such that no element arr2[j] satisfies |arr1[i] - arr2[j]| <= d.
Given two integer arrays arr1 and arr2 and an integer d, return the distance value: the number of elements arr1[i] such that no element arr2[j] satisfies |arr1[i] - arr2[j]| <= d.
Example 1:
Input: {"arr1":[4,5,8],"arr2":[10,9,1,8],"d":2}
Output: 2
Constraints:
1≤arr1.length,arr2.length≤500
−1000≤arr1[i],arr2[j]≤1000
0≤d≤100
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"arr1":[4,5,8],"arr2":[10,9,1,8],"d":2}
Sort arr2 to [1, 8, 9, 10] so one binary search can find the arr2 value closest above a - d.