We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sales by Match
Sales by Match
Sort by
recency
|
6046 Discussions
|
Please Login in order to post a comment
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
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
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
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