My .net solution


#1
        if (A.Count == 0 || A.Count == 1) return 0;

        HashSet<int> hash = new HashSet<int>(A);
        
        if (hash.Count != A.Count && B == 0) return 1;
        if (hash.Count == A.Count && B == 0) return 0;

        foreach (var item in A)
        {
            if (hash.Contains(item + B)) return 1;
        }

        return 0;