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.
 
Example 1:
Input: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2
Output: 2
Explanation: 
For arr1[0]=4 we have: 
|4-10|=6 > d=2 
|4-9|=5 > d=2 
|4-1|=3 > d=2 
|4-8|=4 > d=2 
For arr1[1]=5 we have: 
|5-10|=5 > d=2 
|5-9|=4 > d=2 
|5-1|=4 > d=2 
|5-8|=3 > d=2
For arr1[2]=8 we have:
|8-10|=2 <= d=2
|8-9|=1 <= d=2
|8-1|=7 > d=2
|8-8|=0 <= d=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
-10^3 <= arr1[i], arr2[j] <= 10^3
0 <= d <= 100

Difficulty: introductory

Starter code:

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        

Solutions:
class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count=0
        for i in arr1:
            flag=0
            for j in arr2:
                if abs(i-j)<=d:
                    flag=1
                    break
            if flag == 0:
                count+=1
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        dist_matrix = [[abs(x-y) for y in arr2] for x in arr1]
         
        return len([1 for dist_lst in dist_matrix if min(dist_lst)>d])


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        return sum([sum([abs(i-j)>d for i in arr2])==len(arr2) for j in arr1])

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        bound = [(n+d,n-d) for n in arr2]
        out = 0
        for n in arr1:
            if any([ Up >= n >= Low for Up, Low in bound]):
                out += 1
        return len(arr1) - out


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        bound = [(n+d,n-d) for n in arr2]
        out = 0
        for n in arr1:
            if all([ n > Up or n < Low for Up, Low in bound]):
                out += 1
        return out


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        return sum([sum([abs(a - b) > d for b in arr2]) == len(arr2) for a in arr1])

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        c = 0
        c1 = 0
        for a in arr1:
            for r in arr2:
                if abs(a - r) > d:
                    c1 += 1
            if c1 == len(arr2):
                c += 1
            c1 = 0
        return c

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        cnt = 0
        fcnt = 0
        lnb = len(arr2)
        for a in arr1:
            cnt = 0
            for b in arr2:
                if abs(a-b) > d:
                    cnt = cnt + 1
            if cnt == lnb:
                fcnt = fcnt + 1
        return fcnt

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        total = 0
        for n in arr1:
            if all(abs(n - _n) > d for _n in arr2):
                total += 1
        return total

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        n, m = len(arr1), len(arr2)
        ans = 0
        for i in range(n):
            flag = 0
            for j in range(m):
                if abs(arr1[i] - arr2[j]) <= d:
                    flag = 1
            if not flag:
                ans+=1
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        qual = []
        
        for k in set(arr1):
            if False not in [True if abs(k-k2)>d else False for k2 in set(arr2)]:
                qual.append(k)
        
        k=0
        
        for q in qual:
            k+=arr1.count(q)
        
        return k
        
        
        


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        
        c = 0
        l2 = len(arr2)
        for i in arr1:
            tmp = 0
            for j in arr2:
                
                if abs(i - j) > d:
                    tmp+=1
                    

                    
            if tmp == l2:
                c += 1
                    
                    
        return c
    
    


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count = 0
        for i in range(len(arr1)):
            is_dist = True
            for j in range(len(arr2)):
                if abs(arr1[i]-arr2[j]) <= d:
                    is_dist = False
            
            if is_dist == True:
                count += 1
                
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count = 0
        for i in range(len(arr1)):
            flag = 0
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j])<=d:
                    flag = 1
            if flag ==1:
                count+=1
        return(len(arr1) - count)

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        m = len(arr1)
        n = len(arr2)
        
        distance = 0
        for i in range(m):
            is_valid = True
            for j in range(n):
                if abs(arr1[i]-arr2[j])<= d:
                    is_valid = False
            if is_valid:
                distance += 1
        return distance

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        n = len(arr1)
        m = len(arr2)
        count = 0
        for i in range(n):
            bad = False
            for j in range(m):
                if abs(arr1[i] - arr2[j]) <= d:
                    bad = True
            if not bad:
                count+=1
            
        return count


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:

        arr = []
        for i in range(len(arr1)):
            count = 0
            for j in range(len(arr2)):
                if(abs(arr1[i]-arr2[j])<=d):
                    count = count+1
            if(count==0):
                arr.append(arr1[i])
        return len(arr)

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        c = 0
        for i in range(len(arr1)):
            f = 0
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j])<=d:
                    f = 1
            if f==1:
                c+=1
        return(len(arr1) - c)


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        op = 0
        for i in range(len(arr1)):
            ref = [abs(arr1[i] - a2) <= d for a2 in arr2]
            if sum(ref) == 0:
                op += 1
        return op
    # def findTheDistanceValue(self, A, B, d):
    #     return sum(all(abs(a - b) > d for b in B) for a in A)


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        dists = []
        for x in arr1:
            dists.append([abs(x-y) > d for y in arr2])
        
        return sum([all(x) for x in dists])

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count =0
        for i in arr1 :
            new_list= list(map(lambda m : abs(m -i), arr2))
            if all(x>d for x in new_list):
                count += 1
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count =0
        for i in arr1 :
            new_list= list([abs(m -i) for m in arr2])
            if all(x>d for x in new_list):
                count += 1
        return count
            


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count=0
        for i in range(len(arr1)):
            for j in range (len(arr2)):
                a= abs((arr1[i])-(arr2[j]))
                if  (a<=d):
                    break
            else:
                count=count+1
        return (count)        


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count = len(arr1)
        for i in range(len(arr1)):
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j]) <= d:
                    count -= 1
                    break
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count=0
        for i in range(len(arr1)):
            for j in range(len(arr2)):
                if abs(arr1[i]-arr2[j])<=d:
                    break
            else:
                count=count+1
                    
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        c = 0
        for i in range(len(arr1)):
            temp = 0
            for j in range(len(arr2)):
                if(abs(arr1[i]-arr2[j])<=d):
                    temp = 1
                    break
            if(temp == 0):
                c+=1
        return c


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:     
        el_num = 0
        
        for i in range(len(arr1)):
            el_num += 1
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j]) <= d:
                    el_num -= 1
                    break
        
        return el_num

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        forbid_set = set()
        for a2 in arr2:
            forbid_set |= set(range(a2-d, a2+d+1))
            
        return sum(1 for a1 in arr1 if a1 not in forbid_set)

from collections import Counter
class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr1, arr2 = Counter(arr1), set(arr2)
        
        # print(arr1)
        # print(arr2)
        
        res = 0
        for num in arr1:
            target = range(num - d, num + d + 1)
            if not arr2.intersection(target):
                res += arr1[num]
        
        return res

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        val = 0
        dist = 0
        for i in range(0,len(arr1)):
            for j in range(0,len(arr2)):

                if abs(arr1[i]-arr2[j]) > d:
                    val += 1
                else:
                    break
            if val == len(arr2):
                dist += 1
            val = 0
        return dist

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        count = 0
        
        for i in range(len(arr1)):
            for j in range(len(arr2)):
                temp = arr1[i] - arr2[j]
                if temp < 0 :
                    temp = -temp
                    
                if temp <= d :
                    break
                    
                if j == len(arr2) - 1:
                    count += 1
        return count


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        distanceValue = 0
        
        for i in range(len(arr1)):
            val = arr1[i]
            shouldCount = True
            for j in range(len(arr2)):
                if abs(val - arr2[j]) <= d:
                    shouldCount = False
                    break
            if shouldCount == True:
                distanceValue+=1
        return distanceValue

class Solution:
    def findTheDistanceValue(self, arr1, arr2, d):
        d = abs(d);
        res = 0
        for i in range(len(arr1)):
            count = 0
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j]) <= d:
                    break
                else:
                    count += 1
                if count == len(arr2):
                    res += 1
        return res
    
sol = Solution();
x = sol.findTheDistanceValue([4,5,8],[10,9,1,8],2);
print(x);


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        c=len(arr1)
        for i in arr1:
            for j in arr2:
                if abs(i-j)<=d:
                    c-=1
                    break
        return c

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        ans = 0
        for x in arr1:
            for y in arr2:
                if abs(x-y) <= d:
                    break
            else:
                ans += 1
                continue
        return ans

class Solution:
    def findTheDistanceValue(self, a1: List[int], a2: List[int], d: int) -> int:
        x = set(a1)
        x -= {a + i for a in a2 for i in range(-d, d+1)}
        return sum(n in x for n in a1)

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        dist_matrix = [all(abs(x-y)>d for y in arr2) for x in arr1]
        
        return sum(dist_matrix)
         
        # return len([1 for dist_lst in dist_matrix if min(dist_lst)>d])


class Solution:
    def findTheDistanceValue(self, arr1, arr2, d):
        arr1.sort()
        arr2.sort()
        i = 0
        j = 0
        dist = 0
        while i < len(arr1) and j < len(arr2):
            if arr1[i] >= arr2[j]:
                if arr1[i] - arr2[j] > d:
                    j += 1
                else:
                    i += 1
            else:
                if arr2[j] - arr1[i] > d:
                    i += 1
                    dist += 1
                else:
                    i += 1
        dist += len(arr1) - i
        return dist

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        ans = 0
        for i in arr1:
            for j in arr2:
                if abs(i-j) <= d:
                    break
            else:
                ans += 1
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count=0
        for i in arr1:
            for j in arr2:
                if abs(i-j)<=d:
                    break
            else:
                count+=1
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        nums = set()
        for number in arr2:
            for n in range(number-d, number+d+1):
                nums.add(n)
            
        cnt = 0
        for number in arr1:
            if number not in nums:
                cnt += 1
        
        return cnt

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        '''count=0
        for x,y in zip(arr1[:],arr2[:]):
            print(x,y)
            if abs(x-y)<d:
                count=count+1
        return count'''
        cnt = 0
        
        for i in arr1:
            for j in arr2:
                if abs(i-j) <= d:
                    break
            else:
                cnt += 1
        return cnt


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr = []
        for i in range(len(arr1)):
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j]) <=d:
                    arr.append(arr1[i])
                    break
        print(arr)
                    
        return len(arr1) - len(arr)


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        distance_value=[]
        for i in arr1:
            valid=True
            for j in arr2:
                if abs(i-j)<=d:
                    valid=False
                    break
            if valid:
                distance_value.append(i)
        return len(distance_value)

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count=0
        for i in range(len(arr1)):
            for j in range(len(arr2)):
                flag=1
                if abs(arr1[i]-arr2[j])<=d:
                    break
                else:
                    flag=0
            if flag==0:
                count=count+1
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        print([x for x in arr1 if all (abs(x-y) > d for y in arr2)])
        return len([x for x in arr1 if all (abs(x-y) > d  for y in arr2)])

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        cnt = 0
        for i in range(len(arr1)):
            cnt += 1
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j]) <= d:
                    cnt -= 1
                    break
        return cnt

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr1 = sorted(arr1)
        arr2 = sorted(arr2)
        
        i1 = 0
        i2 = 0
        ans = 0
        while i1 < len(arr1):
            while i2 < len(arr2) and arr2[i2] < arr1[i1]:
                i2 += 1
            
            if i2 == 0:
                ans = ans + 1 if abs(arr2[i2] - arr1[i1]) > d else ans
            elif i2 == len(arr2):
                ans = ans + 1 if abs(arr2[i2 - 1] - arr1[i1]) > d else ans
            else:
                ans = ans + 1 if min(abs(arr2[i2 - 1] - arr1[i1]), abs(arr2[i2] - arr1[i1])) > d else ans
            
            i1 += 1
        
        return ans


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        # c=0
        # for a in arr1:
        #     t = 1
        #     for b in arr2:
        #         if abs(a-b)<=d:
        #             t*=0
        #         else:
        #             t*=1
        #     if t==1:
        #         c +=1
        # return c
        return sum(all(abs(a - b) > d for b in arr2) for a in arr1)

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        ans = len(arr1)
        for i in range(len(arr1)):
            for j in range(len(arr2)):
                
                if(abs(arr1[i] - arr2[j])) <= d:
                    ans -= 1
                    break
        
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        return sum(all(abs(a - b) > d for b in arr2) for a in arr1)

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        cnt=0
        ans=0
        for i in range(len(arr1)):
            for j in range(len(arr2)):
                if abs(arr1[i]-arr2[j])>d:
                    cnt+=1
                else:
                    cnt=0
                    break
                if j==len(arr2)-1 and cnt==len(arr2):
                    ans+=1
                    cnt=0
                
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr1.sort()
        arr2.sort()
        ans = 0
        for i in arr1:
            is_valid = True
            for j in arr2:
                if abs(i-j)<=d:
                    is_valid = False
                    break
            if is_valid:
                ans += 1
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr2.sort()
        res = len(arr1)
        for i in arr1:
            for j in arr2:
                if abs(i - j) <= d:
                    res -= 1
                    break
        return res
        
#         res = 0
#         cnt = 0
#         l = len(arr2)
#         for i in arr1:
#             for j in arr2:
#                 if abs(i - j) > d:
#                     cnt += 1
#             if cnt == l:
#                 res += 1
#                 cnt = 0
#         return res
        


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr2.sort()
        ans = 0
        for i in arr1:
            is_valid = True
            for j in arr2:
                if abs(i-j)<=d:
                    is_valid = False
                    break
            if is_valid:
                ans += 1
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        count = 0
        arr2.sort()
        
        
        for i in arr1:
            for j in arr2:
                if abs(i-j) <= d:
                    break
            else:
                count += 1
                
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        Distance = 0
        for x in arr1:
            if all(abs(x-y) > d for y in arr2):
                Distance += 1
        return Distance

def bs(a, t, d):
    l, r = 0, len(a)
    while l < r:
        mid = l + (r - l) // 2
        if abs(a[mid] - t) <= d:
            return 0
        elif a[mid] > t:
            r = mid
        else:
            l = mid + 1
    return 1

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        total = 0
        arr2.sort()
        for n in arr1:
            total += bs(arr2, n, d)
        return total

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        total = 0
        
        arr1.sort()
        arr2.sort()
        
        for i in arr1:
            for j in arr2:
                if abs(i-j) <= d:
                    total -=1
                    break
            total += 1
        
        return total

from collections import Counter

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        res = 0
        cnt = Counter(arr2)
        for n in arr1:
            td = d
            vals_to_find = []
            while td >= -d:
                vals_to_find.append(n - td)
                td -= 1
            add = True
            for j in vals_to_find:
                if cnt[j] > 0:
                    add = False
                    break
            if add:
                res += 1
        return res

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count = 0
        l = len(arr2)
        arr2.sort()
        for i in arr1:
            temp_count = 0
            for j in arr2:
                if(abs(i-j) <= d):
                    break
                else:
                    temp_count += 1
            if(temp_count == l):
                count += 1
            temp_count = 0
        return count 

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        ans = 0
        
        arr2.sort()
        
        for i in range(len(arr1)):
            
            flag = True
            
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j]) <= d:
                    flag = False
                    break
                    
            if flag:
                ans += 1
                
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr1.sort()
        arr2.sort()
        m=len(arr1)
        n=len(arr2)
        cnt=0
        for i in range(m):
            flag=True
            for j in range(n):
                dis=abs(arr1[i]-arr2[j])
                if(dis<=d):
                    flag=False
                    break
            if(flag):
                cnt+=1
                
        return cnt



class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        dpcache = {}
        distance = 0
        
        for el1 in arr1:
            # check cache for this number
            if dpcache.get(el1) is True:
                distance += 1
                continue
            elif dpcache.get(el1) is False:
                continue
            else:
                # otherwise go and calculate solution for cur number
                pass
            
            for el2_idx, el2 in enumerate(arr2): 
                # if condition fails, save failure in cache
                if abs(el1 - el2) <= d:
                    dpcache[el1] = False
                    break
                    
                # if condition wins, save it in cache too
                if el2_idx == len(arr2) - 1:
                    dpcache[el1] = True
                    distance += 1
                    
        return distance

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        arr2.sort()
        count = len(arr1)
        
        for i in range(len(arr1)):
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j])<= d:
                    count-= 1
                    break
                
        return count
                    
            


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr1.sort()
        arr2.sort()        
        
        el_num = 0
        
        for i in range(len(arr1)):
            el_num += 1
            for j in range(len(arr2)):
                if abs(arr1[i] - arr2[j]) <= d:
                    el_num -= 1
                    break
        
        return el_num

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr2.sort()
        res = 0
        for i in arr1:
            found = True
            for j in arr2:
                
                if j > i + d:
                    break
                elif abs(i - j) <= d:
                    found = False
                    break
            res += found        
        return res    


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        def min_d(num, arr):            
            # use binary search to find the first arr element >= than num 
            left = 0
            right = len(arr2) - 1            
            while left <= right:
                mid = (left + right) // 2                
                if arr[mid] < num:
                    left = mid + 1
                else:
                    right = mid - 1
           
            if left == len(arr):  # all elements less than num
                return num - arr[-1]
            elif left == 0: # all elements greater than num
                return arr[0] - num            
            return min(arr[left] - num, num - arr[left-1])
                
        arr2.sort()         
        distance = 0        
        for num in arr1:
            if min_d(num, arr2) > d:
                distance += 1
                
        return  distance

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr2.sort()
        tot = 0
        for i in arr1:
            found = False
            for j in arr2:
                diff = i - j
                if abs(diff) <= d:
                    found = True
                    break
                if diff <= -d:
                    break
            if not found:
                tot += 1
        return tot

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        arr2.sort()
        ans = 0
        
        for base in arr1:
            count = 0
            idx = 0
            while idx < len(arr2) and base > arr2[idx]: idx += 1  # util arr2[idx] >= base
            if idx == 0:
                ans += abs(base - arr2[idx]) > d
            elif idx == len(arr2):
                ans += abs(base - arr2[idx - 1]) > d
            else:
                ans += ((abs(base - arr2[idx]) > d) and (abs(base - arr2[idx-1]) > d))
                
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        ok = 0
        arr2.sort()        
        for test1 in arr1:
            ele = 0
            sign = 0
            for test2 in arr2:     
                test = test2-test1
                if abs(test) <= d: 
                    ele = 1
                    break
                if (test > d) or (d < 0):
                    break
            if ele == 0: ok += 1
        return ok

import numpy

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr2.sort()
        s = 0
        n2 = len(arr2)
        for x in arr1:
            k = numpy.searchsorted(arr2, x)
            if k < n2 and arr2[k] - x <= d:
                s += 1
            else:
                if k >= 1 and x - arr2[k - 1] <= d:
                    s += 1
        return len(arr1) - s
                


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count = 0
        for a in set(arr1):
            if all(abs(a - b) > d for b in set(arr2)):
                count += arr1.count(a)
        return count

import numpy

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        arr2 = sorted(arr2)
        s = len(arr1)
        n2 = len(arr2)
        for x in arr1:
            k = numpy.searchsorted(arr2, x)
            if k < n2 and arr2[k] - x <= d:
                s -= 1
            else:
                if k >= 1 and x - arr2[k - 1] <= d:
                    s -= 1
        return s
                


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count=0
        for i in arr1:
            add=1
            for j in range(d+1):
                if (i+j) in arr2 or (i-j) in arr2:
                    add=0
                    break
            count+=add
        return count

import numpy as np
class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        res=0
        for num1 in arr1:
            if all(abs(np.subtract(num1,arr2))>d):
                res+=1
        return res

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        ans = 0
        for num1 in arr1:
            flag = 1
            for num2 in arr2:
                if abs(num1 - num2) <= d:
                    flag = 0
            if flag:
                ans+=1
        return ans                    
        


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        res = 0
        for a in arr1:
            temp = True
            for b in arr2:
                if(abs(a-b) <= d):
                    temp = False
            if(temp):
                res += 1
        return res


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        distance = 0
        for i in arr1:
            is_there = False
            for j in arr2:
                if abs(i-j)>d:
                    continue
                else:
                    is_there = True
            if not is_there:
                distance+=1
        return distance


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        count=0
        for i in arr1:
            flag=False
            for j in arr2:
                if abs(i-j)<=d:
                    flag=True
            if flag==False:
                count+=1
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        r = 0
        for i in arr1:
            ir = 1
            for j in arr2:
                if abs(i - j) <= d:
                    ir = 0
                    continue
            r += ir
        return r


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        result = 0
        for i in arr1:
            a = 1
            for j in arr2:
                if abs(i-j)<=d:
                    a = 0
            result += a
        return result


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count=0
        for i in arr1:
            yes=0
            for j in arr2:
                    if abs(i-j)<=d:
                        yes=1
                        # break
            if(yes==1):
                count+=1
        return len(arr1)-count


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        cnt=0
        for a in arr1:
            mark=0
            for b in arr2:
                if abs(a-b) <=d:
                    mark=1
            cnt+=1 if mark==0 else 0
        return cnt


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        distance = [[val - d, val + d] for val in arr1]
        total = 0
        for ran in distance:
            for val in arr2:
                if(ran[0] <= val and val <= ran[1]):
                    total += 1
                    break
        return len(arr1) - total
                
                
            


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        result = 0
        for num in arr1:
            greater = True
            for sub in arr2:
                if abs(num-sub) <= d:
                    greater = False
            if greater:
                result += 1
        return result

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count = 0
        for num1 in arr1:
            flag = False
            for num2 in arr2:
                if abs(num1 - num2) <= d:
                    flag = True
            if not flag:
                count += 1
        return count


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count=0
        for i in arr1:
            flag=0
            for j in arr2:
                if abs(i-j)<=d:
                    flag=1
            if flag==0:
                count+=1
        return count

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count = 0
        for i in arr1:
            curr = 0
            for j in arr2:
                if abs(i-j) <= d:
                    curr += 1
            
            if curr == 0:
                count += 1
        
        return count


class Solution:
    def findTheDistanceValue(self, arr1, arr2, d: int) -> int:
        counter = 0
        if 1 <= len(arr1) <= 500 and 1 <= len(arr2) <= 500:
            for i in range(len(arr1)):
                val = 1
                for j in range(len(arr2)):
                    if pow(-10, 3) <= arr1[i] <= pow(10, 3) and pow(-10, 3) <= arr2[j] <= pow(10, 3):
                        if 0 <= d <= 100:
                            check_value = (abs(arr1[i] - arr2[j]))
                            if check_value <= d:
                                val = 0
                                break
                if val == 1:
                    counter += 1
            # print(counter)
            return counter

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        boss = 0 
        for val1 in arr1 : 
            cnt = 0 
            for val2 in arr2 : 
                if abs(val2 - val1) <= d : 
                    cnt += 1 
            if cnt == 0 : 
                boss += 1 
        return boss
                


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        ans=0
        for i in arr1:
            for j in range(i-d,i+d+1):
                if(j in arr2):
                    break
                    
            else:
                ans+=1
        return ans

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        ans = 0
        for x in arr1:
            ans += all([abs(x-y) > d for y in arr2])
        return ans


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        ans = 0
        
        for a in arr1:
            isGood = True
            
            for b in arr2:
                if (abs(a-b)<=d):
                    isGood = False
                    break
            
            if (isGood): 
                ans += 1
        
        return ans
                


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        res = 0
        for a in arr1:
            add = True
            for b in arr2:
                if abs(a - b) <= d:
                    add = False
            if add:
                res += 1
        return res

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        c = list(set([i for i in arr1 for j in arr2 if abs(i-j) <= d ]))
        i = len(arr1)
        for j in c:
            i -= arr1.count(j)
        return i


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        return sum([1 - any([abs(i-j) <= d for j in arr2]) for i in arr1])

class Solution:
    def findTheDistanceValue(self, A: List[int], B: List[int], d: int) -> int:
        return sum(1 - any([abs(a - b) <= d for b in B]) for a in A)

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        return sum([all([abs(i-j) > d for j in arr2]) for i in arr1])

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        
        count=0
        for i in arr1:
            a = True
            for j in arr2:
                a=a & (abs(i-j)>d)
            if a==True:
                count+=1
        return count 

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        a = set()
        out=0
        for i in range(len(arr1)):
            for j in arr2:
                if abs(arr1[i]-j)<=d:
                    out+=1
                    if i not in a:
                        a.add(i)

        return len(arr1)-len(a)

class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        return len([g for g in [min(k) for k in [[abs(t - y) for t in arr2] for y in arr1]] if g>d])


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
        count = 0
        for i in arr1:
            d_l = [abs(i-j) > d for j in arr2]
            if all(d_l):
                count += 1
        return count
                


class Solution:
    def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:

        final_count = 0
        for arr_1_val in arr1:
            #store the matches
            correct_count = 0
            for arr_2_val in arr2:

                if abs(arr_1_val- arr_2_val) > d:
                    correct_count += 1
            if correct_count == len(arr2):
                final_count += 1
        return final_count