Sort by

recency

|

6046 Discussions

|

  • + 0 comments

    def sockMerchant(n, ar): # Write your code here count=0 y= Counter(ar) for i in y.values(): t=int(i/2) count+=t * return count

  • + 0 comments

    def sockMerchant(n, ar): # Write your code here count=0 y= Counter(ar) for i in y.values(): t=int(i/2) count+=t * return count

  • + 0 comments

    def sockMerchant(n, ar): # Write your code here count=0 y= Counter(ar) for i in y.values(): t=int(i/2) count+=t return count

  • + 0 comments
    def sockMerchant(n, ar):
        # Write your code here
        
        temp = {}
        pairs = 0
        for i in ar:
            if not temp.get(i):
                temp[i] = 1
            else:
                temp[i] = 0
                pairs += 1
        return pairs
    
  • + 0 comments

    My solution with Python

    def sockMerchant(n, ar): # Write your code here ar.sort() count = 0 dict = {} for number in ar: if number not in dict: dict[number] = 1 else: value = dict.get(number) dict[number] = value + 1

    for key, value in dict.items():
        count += (value // 2)
    
    return count