-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ1157.java
More file actions
32 lines (27 loc) · 794 Bytes
/
Copy pathJ1157.java
File metadata and controls
32 lines (27 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package TIL;
import java.util.Scanner;
public class J1157 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char[] str = scanner.nextLine().toUpperCase().toCharArray();
int index =0;
int[] word= new int[26];
int max_num = 0;
for (int i = 0; i < str.length; i++)
{
index = str[i] - 'A';
word[index]++;
if (word[max_num] < word[index])
max_num = index;
}
for(int i = 0; i < 26; i++)
{
if(i == max_num) continue;
if(word[max_num] == word[i]){
System.out.println("?");
System.exit(0);
}
}
System.out.println((char)(max_num+'A'));
}
}