C++ | Easy two pointer approach


#1

Comment body goe**`int Solution::diffPossible(vector &A, int B) {

int n = A.size();

int i = 0, j = i+1;

while(j < n){
    
    while(i < n && i < j && A[j] - A[i] > B){
           i++;
    }
    if(A[j]-A[i] == B && i!=j) return 1;
    j++;
}
return 0;

}

`**s here.