public static void main(String args[]){
        CountNDistinctPairsWithDifferenceK cn = new CountNDistinctPairsWithDifferenceK();
        int arr[] = {1,2,3,4,5,7,9};
        System.out.print(cn.count(arr, 3));
    }
http://www.geeksforgeeks.org/count-pairs-difference-equal-k/
src/com/interview/binarysearch/CountNDistinctPairsWithDifferenceK.java