Solution: Python
def sockMerchant(n, ar):
d = dict()
for a in ar:
if a in d.keys():
d[a] += 1
else:
d[a] = 1
re = 0
for k in d.keys():
re += (d[k] // 2)
return re
Solution: Python
def sockMerchant(n, ar):
d = dict()
for a in ar:
if a in d.keys():
d[a] += 1
else:
d[a] = 1
re = 0
for k in d.keys():
re += (d[k] // 2)
return re