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
|
6034 Discussions
|
Please Login in order to post a comment
Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-sales-by-match-problem-solution.html
Python
def sockMerchant(n, arr): freq={} for i in range(n): if arr[i] in freq: freq[arr[i]]+=1 else: freq[arr[i]]=1 return sum(v//2 for k,v in freq.items())
a=int(input()) b=list(map(int,input().split())) s=set(b) d=[] w=0 for i in s: r=b.count(i) d.append(r)
for i in d: if int(i)>=2: t=int(i)//2 w=w+t
print(w)
JavaScript
Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-sales-by-match-problem-solution.html