forked from RyanFehr/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
33 lines (28 loc) · 784 Bytes
/
Solution.java
File metadata and controls
33 lines (28 loc) · 784 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
//Problem: https://www.hackerrank.com/challenges/migratory-birds
//Java 8
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] types = new int[5];
for(int types_i=0; types_i < n; types_i++){
int type = in.nextInt()-1;
types[type] = types[type] +1;
}
int max = 0, index = 0;
for(int i = 0; i < 5; i++)
{
if(types[i] > max)
{
max = types[i];
index = i;
}
}
System.out.println(index+1);
}
}