import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next().toUpperCase();
int[] count = new int[26];
int max = 0;
char answer = '?';
int num;
for (int i = 0; i < str.length(); i++) {
num = str.charAt(i) - 'A';
count[num]++;
}
for (int i = 0; i < count.length; i++) {
if(max < count[i]){
max = count[i];
answer = (char)(i+'A');
} else if (max == count[i]){
answer = '?';
}
}
System.out.println(answer);
sc.close();
}
}
toUpperCase 메서드를 이용하여 모든 알파벳을 대문자로 취급했다.
'Algorithm > Baekjoon' 카테고리의 다른 글
[백준_JAVA] 2903 중앙 이동 알고리즘 (0) | 2023.08.29 |
---|---|
[백준_JAVA] 11005 진법 변환 2 (0) | 2023.08.28 |
[백준_JAVA] 2720 세탁소 사장 동혁 (0) | 2023.08.18 |
[백준_JAVA] 2501 약수 구하기 (0) | 2023.08.17 |
[백준_JAVA] 10101 삼각형 외우기 (0) | 2023.08.15 |