Practice Find the Distance Value Between Two Arrays
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Easy#1385
LeetCode ProblemFind the Distance Value Between Two Arrays
Problem Statement
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.
Source: Find the Distance Value Between Two Arrays on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2
Output
2
# Example 2
Input
arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3
Output
2
# Example 3
Input
arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6
Output
1
Constraints
1 <= arr1.length, arr2.length <= 500
-1000 <= arr1[i], arr2[j] <= 1000
0 <= d <= 100
Related LeetCode Problems
Practice more problems similar to Find the Distance Value Between Two Arrays.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.