leetcode1385
Posted AsenYang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode1385相关的知识,希望对你有一定的参考价值。
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
算法思路:遍历数组。
以上是关于leetcode1385的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode --- 1385. Find the Distance Value Between Two Arrays 解题报告
leetcode_1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold_[二维前缀和](代码片段