public Triplet findTriplet(int input[], int sum) {
        Arrays.sort(input);
        for (int i = 0; i < input.length - 2; i++) {

            int start = i + 1;
            int end = input.length - 1;
            int new_sum = sum - input[i];
            while (start < end) {
                if (new_sum == input[start] + input[end]) {
                    Triplet t = new Triplet();
                    t.a = input[i];
                    t.b = input[start];
                    t.c = input[end];
                    return t;
                }
                if (new_sum > input[start] + input[end]) {
                    start++;
                } else {
                    end--;
                }
            }
        }
        return null;
    }
http://www.geeksforgeeks.org/find-a-triplet-that-sum-to-a-given-value/
src/com/interview/array/TripletInArray.java