1486. Find the Distance Value Between Two Arrays
My accepted Python solution to LeetCode problem 1486, Find the Distance Value Between Two Arrays, running in 27ms.
- Difficulty: Easy
- Python
- Runtime 27ms
- Memory 17.7MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 27ms, memory 17.7MB, accepted 2025-12-30.
class Solution:
def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
count = 0
for a in arr1:
if all(abs(a - b) > d for b in arr2):
count += 1
return count