휴지통/알고리즘 & 자료구조
백준 1157_1
신재권
2022. 3. 11. 00:19
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main1157 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine().toUpperCase();
int[] cnt = new int[26];
int max = 0;
char maxAlpha = '?';
for(int i=0; i<s.length(); i++) {
cnt[s.charAt(i)-'A']++;
if(max < cnt[s.charAt(i)-'A']) {
max = cnt[s.charAt(i)-'A'];
maxAlpha = s.charAt(i);
}else if(max == cnt[s.charAt(i)-'A']) maxAlpha='?';
}
System.out.println(maxAlpha);
}
}