• + 1 comment

    Python:

    def pickingNumbers(a):
        s=[]
        c1,c2=0,0
        for i in range(len(a)):
            for j in range(len(a)):
                if a[i] in [a[j],a[j]-1]:
                    c1+=1
                if a[i] in [a[j],a[j]+1]:
                    c2+=1
            s.append(c1)
            s.append(c2)
            c1=0
            c2=0
        return max(s)