public static int findPairs2(int[] arr, int k){
        int count = 0;
        Set<Integer> set = new HashSet<Integer>();
        for(int num : arr){
            if(!set.contains(num))set.add(num);
        }

        for(int num : arr){
            int target = num + k;
            if(set.contains(target)){
                System.out.println(num + " " + target);
                count++;
            }
        }
        return count;
    }