|
1 | 1 | packagecom.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 1385. Find the Distance Value Between Two Arrays |
5 |
| - * |
6 |
| - * Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays. |
7 |
| - * 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. |
8 |
| - * |
9 |
| - * Example 1: |
10 |
| - * Input: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2 |
11 |
| - * Output: 2 |
12 |
| - * Explanation: |
13 |
| - * For arr1[0]=4 we have: |
14 |
| - * |4-10|=6 > d=2 |
15 |
| - * |4-9|=5 > d=2 |
16 |
| - * |4-1|=3 > d=2 |
17 |
| - * |4-8|=4 > d=2 |
18 |
| - * For arr1[1]=5 we have: |
19 |
| - * |5-10|=5 > d=2 |
20 |
| - * |5-9|=4 > d=2 |
21 |
| - * |5-1|=4 > d=2 |
22 |
| - * |5-8|=3 > d=2 |
23 |
| - * For arr1[2]=8 we have: |
24 |
| - * |8-10|=2 <= d=2 |
25 |
| - * |8-9|=1 <= d=2 |
26 |
| - * |8-1|=7 > d=2 |
27 |
| - * |8-8|=0 <= d=2 |
28 |
| - * |
29 |
| - * Example 2: |
30 |
| - * Input: arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3 |
31 |
| - * Output: 2 |
32 |
| - * |
33 |
| - * Example 3: |
34 |
| - * Input: arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6 |
35 |
| - * Output: 1 |
36 |
| - * |
37 |
| - * Constraints: |
38 |
| - * 1 <= arr1.length, arr2.length <= 500 |
39 |
| - * -10^3 <= arr1[i], arr2[j] <= 10^3 |
40 |
| - * 0 <= d <= 100 |
41 |
| - * */ |
42 | 3 | publicclass_1385 {
|
43 | 4 | publicstaticclassSolution1 {
|
44 | 5 | publicintfindTheDistanceValue(int[]arr1,int[]arr2,intd) {
|
|