We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 52efc03 commit bd55960Copy full SHA for bd55960
HackerRank-Sock Merchant/Sock_Merchant.py
@@ -0,0 +1,34 @@
1
+#!/bin/python3
2
+
3
+import math
4
+import os
5
+import random
6
+import re
7
+import sys
8
9
+# Complete the sockMerchant function below.
10
+def sockMerchant(n, ar):
11
+ count = 0
12
+ ar.sort()
13
+ ar.append('#')
14
+ i = 0
15
+ while i<n:
16
+ if ar[i]==ar[i+1]:
17
+ count = count+1
18
+ i+=2
19
+ else:
20
+ i+=1
21
+ return count
22
23
+if __name__ == '__main__':
24
+ fptr = open(os.environ['OUTPUT_PATH'], 'w')
25
26
+ n = int(input())
27
28
+ ar = list(map(int, input().rstrip().split()))
29
30
+ result = sockMerchant(n, ar)
31
32
+ fptr.write(str(result) + '\n')
33
34
+ fptr.close()
0 commit comments