Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit db5574a

Browse files
Solution accepted
1 parent f0379a6 commit db5574a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

‎HackerRank-Sock-Merchant/solution.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
def sockMerchant(n, ar):
10+
count = 0
11+
ar.sort()
12+
ar.append('#')
13+
i = 0
14+
while i<n:
15+
if ar[i]==ar[i+1]:
16+
count = count+1
17+
i+=2
18+
else:
19+
i+=1
20+
return count
21+
22+
if __name__ == '__main__':
23+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
24+
25+
n = int(input())
26+
27+
ar = list(map(int, input().rstrip().split()))
28+
29+
result = sockMerchant(n, ar)
30+
31+
fptr.write(str(result) + '\n')
32+
33+
fptr.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /