Return all pairs from a list of integers that contributes to a given sum Given a list of integers return all the pairs that makes up to a given
  target sum.
  
  input: {2, 7, 11, 15, -2}  target sum: 9
  
  This should return all the pairs i.e {-2,11} and {7,2}.
  
  If there are duplicates that form the same pair, they should not be
  returned.


Here is the code for this problem - would be great to know how this can be refactored for improvement.

   public class TwoSum {
    static class Pair {
        int x, y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (o == null) {
                return false;
            }

            if (o instanceof Pair) {
                Pair other = (Pair) o;
                if (other.x == this.x &amp;&amp; other.y == this.y) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public String toString() {
            return new StringBuilder().append("{").append(this.x).append(",").append(this.y).append("}").toString();
        }
    }

    public static Set&lt;Pair&gt; findPairs(int inputs[], int targetSum) {
        Set&lt;Pair&gt; results = new HashSet&lt;&gt;();
        Map&lt;Integer, Integer&gt; map = new HashMap&lt;&gt;();

        for (int number : inputs) {
            int remainingSum = targetSum - number;

            if (map.containsKey(number)) {
                results.add(new Pair(number, map.get(number)));
            } else {
                map.put(remainingSum, number);
            }
        }
        return results;
    }


To invoke this code:

System.out.println(TwoSum.findPairs(new int[]{2, 7, 11, 15, -2}, 9));


This would print:

[{-2,11}, {7,2}]


Code here: 

https://github.com/Ramblers-Code/CodeKata/blob/master/src/main/java/kata/array/TwoSum.java
I see that you are overriding Object.equals(Object) without overriding Object.hashCode(). By doing this, you violate the contract of Object.hashCode() (see the last paragraph in the description of Object.equals(Object)). In fact, the HashSet&lt;Pair&gt; created in your findPairs method might not operate properly due to this.
Since the values of x and y of a Pair instance never change, you could make x and y final, thereby making Pair an immutable class and preventing accidental tampering with the values of x and y.
I don't know if you've considered this, but your code would treat {2,3} and {3,2} as two distinct pairs. Due to how the findPairs method works, it doesn't matter, since it will never create two pairs that only differ in the order of the two numbers, but I thought I'd point it out in case you were not aware of that.
The null check in Pair.equals(Object) is redundant, since null instanceof X, with X being the name of class, will always return false.
if (o instanceof Pair) {
    Pair other = (Pair) o;
    if (other.x == this.x &amp;&amp; other.y == this.y) {
        return true;
    }
}
return false;


can be written more concise as:

if (o instanceof Pair) {
    Pair other = (Pair) o;
    return other.x == this.x &amp;&amp; other.y == this.y;
}
return false;

new StringBuilder().append("{")


can also be shortened:

new StringBuilder("{")

You don't actually need a Map&lt;Integer, Integer&gt; in findPairs. The mapping of integers to their complement serves no purpose, because the complement of an integer can be simply calculated by subtracting it from the target sum. A Set&lt;Integer&gt; would suffice, since you just use the map to determine whether the complement of a number has already appeared in the sequence of numbers. So findPairs can be re-written as:

public static Set&lt;Pair&gt; findPairs(int inputs[], int targetSum) {
    Set&lt;Pair&gt; results = new HashSet&lt;&gt;();
    Set&lt;Integer&gt; pastNumbers = new HashSet&lt;&gt;();

    for (int number : inputs) {
        int remainingSum = targetSum - number;

        if (pastNumbers.contains(remainingSum)) {
            results.add(new Pair(number, remainingSum));
        } else {
            pastNumbers.add(number);
        }
    }
    return results;
}