Class Solution
java.lang.Object
g1301_1400.s1385_find_the_distance_value_between_two_arrays.Solution
1385 - Find the Distance Value Between Two Arrays.<p>Easy</p>
<p>Given two integer arrays <code>arr1</code> and <code>arr2</code>, and the integer <code>d</code>, <em>return the distance value between the two arrays</em>.</p>
<p>The distance value is defined as the number of elements <code>arr1[i]</code> such that there is not any element <code>arr2[j]</code> where <code>|arr1[i]-arr2[j]| <= d</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong></p>
<p>For arr1[0]=4 we have:</p>
<p>|4-10|=6 > d=2</p>
<p>|4-9|=5 > d=2</p>
<p>|4-1|=3 > d=2</p>
<p>|4-8|=4 > d=2</p>
<p>For arr1[1]=5 we have:</p>
<p>|5-10|=5 > d=2</p>
<p>|5-9|=4 > d=2</p>
<p>|5-1|=4 > d=2</p>
<p>|5-8|=3 > d=2</p>
<p>For arr1[2]=8 we have:</p>
<p><strong>|8-10|=2 <= d=2</strong></p>
<p><strong>|8-9|=1 <= d=2</strong></p>
<p>|8-1|=7 > d=2</p>
<p><strong>|8-8|=0 <= d=2</strong></p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= arr1.length, arr2.length <= 500</code></li>
<li><code>-1000 <= arr1[i], arr2[j] <= 1000</code></li>
<li><code>0 <= d <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
findTheDistanceValue
public int findTheDistanceValue(int[] arr1, int[] arr2, int d)
-