• + 0 comments

    One explicite loop only.

    def pickingNumbers(a): a.sort()

    cntmax = 0
    
    for el in a[:] :
        cnt0 = a.count(el)
        cnt1 = a.count(el+1)
        cntmax = max(cntmax, cnt0+cnt1)
        a = a[cnt0:]
    return cntmax