/**
* Problem: LeetCode 1385 - Find the Distance Value Between Two Arrays
* Difficulty: Easy
* Language: Java
* Author: CodeByTushu
*/
class Solution {
public int findTheDistanceValue(int[] arr1, int[] arr2, int d) {
int count = 0;
for (int a : arr1) {
boolean ok = true;
for (int b : arr2) {
if (Math.abs(a - b) <= d) {
ok = false;
break;
}
}
if (ok) count++;
}
return count;
}
}
"""
Problem: LeetCode 1385 - Find the Distance Value Between Two Arrays
Difficulty: Easy
Language: Python (Python 3)
Author: CodeByTushu
"""
from typing import List
class Solution:
def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
count = 0
for a in arr1:
ok = True
for b in arr2:
if abs(a - b) <= d:
ok = False
break
if ok:
count += 1
return count
/**
* Problem: LeetCode 1385 - Find the Distance Value Between Two Arrays
* Difficulty: Easy
* Language: C++
* Author: CodeByTushu
*/
#include <vector>
#include <cmath>
using namespace std;
class Solution {
public:
int findTheDistanceValue(vector<int>& arr1, vector<int>& arr2, int d) {
int count = 0;
for (int a : arr1) {
boolean ok = true;
for (int b : arr2) {
if (abs(a - b) <= d) {
ok = false;
break;
}
}
if (ok) count++;
}
return count;
}
};
/**
* Problem: LeetCode 1385 - Find the Distance Value Between Two Arrays
* Difficulty: Easy
* Language: JavaScript
* Author: CodeByTushu
*/
/**
* @param {number[]} arr1
* @param {number[]} arr2
* @param {number} d
* @return {number}
*/
var findTheDistanceValue = function(arr1, arr2, d) {
let count = 0;
for (const a of arr1) {
let ok = true;
for (const b of arr2) {
if (Math.abs(a - b) <= d) {
ok = false;
break;
}
}
if (ok) count++;
}
return count;
};