1 class Solution:
 2     def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:
 3         n1,n2 = len(arr1),len(arr2)
 4         result = 0
 5         for i in range(n1):
 6             cur1 = arr1[i]
 7             count = 0
 8             for j in range(n2):
 9                 cur2 = arr2[j]
10                 if abs(cur1 - cur2) > d:
11                     count += 1
12             if count == n2:
13                 result += 1
14         return result

算法思路:遍历数组。

posted on 2020-03-22 12:34  Sempron2800+  阅读(183)  评论(0编辑  收藏  举报