Check out the question here - Sales by Match
def sockMerchant(n, ar):
pairs = 0
for element in set(ar):
pairs += ar.count(element) // 2
return pairs
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input().strip())
ar = list(map(int, input().rstrip().split()))
result = sockMerchant(n, ar)
fptr.write(str(result) + '\n')
fptr.close()
No comments:
Post a Comment