Sales by Match

  • + 0 comments
    #Sorting, and counting stocks with same color, and division is not necesary
    def sockMerchant(n, ar):
        p = defaultdict(bool)
        c=0
        for num in ar:
            if not p[num]:
                p[num] = True
            else:
                c += 1
                p[num] = False
        return c