Complete the sockMerchant function below: ( Solution In Python)
def sockMerchant(n, ar):
pears = 0
color = set()
for i in range(len(ar)):
if ar[i] not in color:
color.add(ar[i])
else:
pears += 1
color.remove(ar[i])
return pears
if name == 'main':
n = int(input())
ar = list(map(int, input().rstrip().split()))
ar.sort()
result = sockMerchant(n, ar)
print(result)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Complete the sockMerchant function below: ( Solution In Python)
def sockMerchant(n, ar):
pears = 0
color = set()
for i in range(len(ar)):
if ar[i] not in color:
color.add(ar[i])
else:
pears += 1
color.remove(ar[i])
return pears
if name == 'main':