update
This commit is contained in:
11
leetcode_py/2006.py
Normal file
11
leetcode_py/2006.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import List
|
||||
|
||||
|
||||
class Solution:
|
||||
def countKDifference(self, nums: List[int], k: int) -> int:
|
||||
count = 0 # number of pairs
|
||||
for i in range(len(nums)):
|
||||
for j in range(i + 1, len(nums)):
|
||||
if abs(nums[i] - nums[j]) == k:
|
||||
count += 1
|
||||
return count
|
||||
Reference in New Issue
Block a user