Easy less than 10 line solution CPP O(n) time O(1) space


#1

int Solution::diffPossible(vector &A, int B) {
int l=0,r=0;
while(r < A.size()){
int diff = A[r] - A[l];
if(diff == B && r != l) return 1;
if(diff > B) {l++;}
else {r++;}
}
return 0;
}