Description
Given an array of integers nums and integer k, return the number of unique k-diff pairs in the array. A k-diff pair has absolute difference k.
Examples
Input:
nums = [3,1,4,1,5], k = 2Output:
2Explanation:
(1,3) and (3,5).
Input:
nums = [1,1,1,2,2], k = 1Output:
1Explanation:
Only one unique pair (1,2) has absolute difference of 1. Even though there are multiple 1's and 2's in the array, only count unique pairs once.
Input:
nums = [2,4,6,8,10], k = 3Output:
0Explanation:
No pairs in the array have an absolute difference of 3. The differences between adjacent elements are all 2, and other pairs have differences of 4, 6, or 8.
Constraints
- •
1 ≤ nums.length ≤ 10⁴