-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigbirds.py
More file actions
36 lines (28 loc) · 800 Bytes
/
migbirds.py
File metadata and controls
36 lines (28 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#https://www.hackerrank.com/challenges/migratory-birds/problem
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the migratoryBirds function below.
def migratoryBirds(arr):
unique_arr=set(arr)
unique_arr=list(unique_arr)
maxcount=1
for i in range(0,len(unique_arr)):
count=0
for j in range(0,len(arr)):
if unique_arr[i]==arr[j]:
count+=1
if count>maxcount:
maxcount=count
maxelement=unique_arr[i]
return maxelement
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
arr_count = int(input().strip())
arr = list(map(int, input().rstrip().split()))
result = migratoryBirds(arr)
fptr.write(str(result) + '\n')
fptr.close()