Count the total pairs of numbers that have a difference of K
Here is how I am solving this problem :

    void solve ( int *input, int N, int K, int& count) {
        std::sort ( input, input + N);
        for ( int i = 0; i < N; i++) {
            int find_me  = input[i] + K;
            if (std::binary_search (input + i + 1, input + N, find_me )) 
                count++;        
            else
                break;
        }
    }

`input` has `integer` values which is guaranteed to be `unique` and `> 0` , `N` is the number of elements. 

Does anybody see anything wrong with this code, I have submitted this to one programming puzzle contest and bot is saying couple of test cases are failed, I want to know what possible test case this code can fail. 
Count the total pairs of numbers that have a difference of K
===

Here is how I am solving this problem :

    void solve ( int *input, int N, int K, int& count) {
        std::sort ( input, input + N);
        for ( int i = 0; i < N; i++) {
            int find_me  = input[i] + K;
            if (std::binary_search (input + i + 1, input + N, find_me )) 
                count++;        
            else
                break;
        }
    }

`input` has `integer` values which is guaranteed to be `unique` and `> 0` , `N` is the number of elements. 

Does anybody see anything wrong with this code, I have submitted this to one programming puzzle contest and bot is saying couple of test cases are failed, I want to know what possible test case this code can fail. 