Skip to content

Commit b3efcff

Browse files
committed
Find the Distance Value Between Two Arrays
1 parent 12abf0e commit b3efcff

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
""" https://leetcode.com/problems/find-the-distance-value-between-two-arrays/ """
2+
3+
class Solution:
4+
def findTheDistanceValue(self, arr1, arr2, d):
5+
willRemove = []
6+
7+
for i in arr1:
8+
for j in arr2:
9+
if (abs(i - j) <= d):
10+
willRemove.append(i)
11+
break
12+
13+
for i in willRemove:
14+
arr1.remove(i)
15+
16+
return len(arr1)
17+
18+
print(Solution().findTheDistanceValue([2,1,100,3], [-5,-2,10,-3,7], 6))

0 commit comments

Comments
 (0)