You are viewing a single comment's thread. Return to all comments →
This is my sollution:
Set<Integer> numbers = new HashSet<>(); int pairs = 0; for (int n : arr) { numbers.add(n); if(numbers.contains(n+k)) pairs++; if(numbers.contains(n-k)) pairs++; } return pairs;
Pairs
You are viewing a single comment's thread. Return to all comments →
This is my sollution: