"""
from https://codelab.interviewbit.com/problems/diffk2/
"""


class Solution:
    # @param A : tuple of integers
    # @param B : integer
    # @return an integer
    def diffPossible(self, A, B):
        # all combinations is O(N ^ 2)

        s = {A[i]: i for i in range(len(A))}
        for i in range(len(A)):
            wanted = A[i] - B
            if wanted in s and s[wanted] != i:
                return 1
        return 0
        # A[i] - A[j] = k -> A[i] - k = A[j]
