-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1385.两个数组间的距离值.c
More file actions
40 lines (24 loc) · 813 Bytes
/
1385.两个数组间的距离值.c
File metadata and controls
40 lines (24 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* @lc app=leetcode.cn id=1385 lang=c
*
* [1385] 两个数组间的距离值
*/
// @lc code=start
int findTheDistanceValue(int* arr1, int arr1Size, int* arr2, int arr2Size, int d){
int resultCounter = 0;
for (int *arr1Pointer = arr1; arr1Pointer < (arr1 + arr1Size); arr1Pointer++) {
bool flag = true;
for (int *arr2Pointer = arr2; arr2Pointer < (arr2 + arr2Size); arr2Pointer++) {
// printf ("%d, %d, %d\n", arr1[i], arr2[j], abs(arr1[i] - arr2[j]));
if (abs((*arr1Pointer) - (*arr2Pointer)) <= d) {
flag = false;
break;
}
}
if (flag) {
resultCounter++;
}
}
return resultCounter;
}
// @lc code=end