```
class Solution {
public:
int findPairs(vector<int>& nums, int k) {
set<int> s;
for (int i=0; i<nums.size(); ++i) {
for (int j=i+1; j<nums.size(); ++j) {
int smaller = min(nums[i],nums[j]);
int bigger = max(nums[i],nums[j]);
if (bigger-smaller==k) {
s.insert(smaller);
}
}
}
return s.size();
}
};
```