import java.io.*;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int[] cnt = new int[26];
String word = br.readLine().toUpperCase();
if(word.length() == 1){
System.out.println(word);
return;
}
int max = 0;
for(char c : word.toCharArray()){
cnt[c - 'A']++;
max = Math.max(max, cnt[c-'A']);
}
int count = 0;
int idx = 0;
for(int i = 0; i < 26; i++){
if(cnt[i] == max) {
count++;
idx = i;
}
}
System.out.println(
(count == 1 ? (char)(idx + 'A') : "?")
);
}
}
단어 길이가 1이면 그 단어를 출력하고 return
카운팅 정렬 사용
int[] cnt 선언 : 인덱스 0(A) ~ 25(Z)까지 횟수 저장cnt[i] == max 인경우 해당 인덱스 값 저장 + max와 같은 값을 가지는 인덱스 횟수 저장만약 count == 1이라면 중복없이 제일 많이 등장한 값이므로,
(char)(idx+'A') 출력
그게 아니라면 max값이 중복이므로 ? 출력