#Diffk #easy C++ Solution using 2 pointers


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

#2

why did you wrote (l<=r) in the condition of while loop instead of (l<r)?


#3

Is that creating any difference?