Although my solution`s time complexity is O(N^3), I want to know why it is wrong.

```
public class Solution {
public int findPairs(int[] nums, int k) {
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int i = 0; i < nums.length; i++) {
for (int j = i + 1; j < nums.length; j++) {
if (Math.abs(nums[i] - nums[j]) == k) {
if (map.containsKey(nums[i]) && map.get(nums[i]) != nums[j]) {
map.put(nums[j], nums[i]);
} else if (!map.containsKey(nums[i]) && !map.containsValue(nums[i])) {
map.put(nums[i], nums[j]);
} else if (!map.containsKey(nums[i]) && map.containsValue(nums[i])) {
boolean flag = true;
for(Integer val : map.keySet()){
if(val.equals(nums[j])){
flag = false;
}
}
if(flag){
map.put(nums[i], nums[j]);
}
}
}
}
}
return map.size();
}
```

}