题目简单,仅供记录使用。
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext())
{
int times = sc.nextInt();
HashMap<String, Integer> map = new HashMap<>();
for (int i = 0; i < times; i++)
{
String color = sc.next();
if (map.containsKey(color))
map.put(color, map.get(color) + 1);
else
map.put(color, 1);
}
int max = 1;
for (Map.Entry<String, Integer> e:
map.entrySet() ) {
if(e.getValue() > max)
max = e.getValue();
}
List<String> l = new ArrayList<>();
for (Map.Entry<String, Integer> e:
map.entrySet() ) {
if(e.getValue() == max)
l.add(e.getKey());
}
for (String s:
l) {
System.out.println(s);
}
}
}
}