This commit is contained in:
2024-12-11 17:31:43 +08:00
parent fdaa94a0fa
commit 5e6299439c
6 changed files with 182 additions and 19 deletions

11
leetcode_py/2006.py Normal file
View 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