• + 0 comments

    The pythonic way: (not the best solution but it works)

    def sockMerchant(n,ar):
        count = {num:ar.count(num) for num in ar}
        pairs = [int((val/2)) for num,val in count.items()]
        return sum(pairs)