LeetCode solutions

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

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 27ms, memory 17.7MB, accepted 2025-12-30.

python
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

Source