My javascript solution in O(n) (including approach screenshots)

facebook
Tags: #<Tag:0x00007f2426b99168>

#1
function(A, k){
        var i=0,j=1,diff
        while(i<A.length && j<A.length) {
            diff=A[j]-A[i]
            if(i==j) {
                j++
            } else if (diff<k) {
                j++
            } else if (diff >k) {
                i++
            } else if (diff==k) {
                return 1
            }
        }
        return 0
    }