문제 출처: https://www.acmicpc.net/problem/1157
문제
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] counts = new int[26];
int max = -1;
for (char c : reader.readLine().toCharArray()) {
int temp = c - 65;
if (c >= 97) {
temp -= 32;
}
counts[temp]++;
max = Math.max(max, counts[temp]);
}
int count = 0;
int result = -1;
for (int i = 0; i < counts.length; i++) {
if (counts[i] == max) {
count++;
result = i;
}
}
if (count != 1) {
System.out.println("?");
} else {
System.out.println((char) (65 + result));
}
reader.close();
}
}