import java.util.HashMap;
import java.util.Map;
public class AvoidDuplicateVotes {
public static String avoidDuplicateVotes(String[] votes) {
Map<String, Integer> map = new HashMap<>();
for (String candidate : votes) {
if (map.containsKey(candidate)) {
int count = map.get(candidate);
if (count >= votes.length / 2)
return candidate;
map.put(candidate, count + 1);
} else {
map.put(candidate, 1);
}
}
return null;
}
public static void main(String[] args) {
String[] votes = {"A", "B", "C", "A", "B", "A"};
System.out.println(avoidDuplicateVotes(votes));
}
}