-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMigratory_Birds.cpp
More file actions
43 lines (35 loc) · 833 Bytes
/
Migratory_Birds.cpp
File metadata and controls
43 lines (35 loc) · 833 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
37
38
39
40
41
42
43
/**
* Title : Migratory_Birds.cpp
* Author : Tridib Samanta
* Created : 14-01-2020
* Link : https://www.hackerrank.com/challenges/migratory-birds/problem
**/
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n,bird;
scanf("%d",&n);
map<int,int> m;
for(int i=0;i<n;i++) {
scanf("%d",&bird);
m[bird]++;
}
int max_count=-1,max_type=-1;
map<int,int>::iterator itr;
for(itr=m.begin();itr!=m.end();itr++) {
if((itr->second) > max_count) {
max_type=itr->first;
max_count=itr->second;
}
}
printf("%d\n",max_type);
return 0;
}