-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1157.java
More file actions
26 lines (22 loc) · 786 Bytes
/
1157.java
File metadata and controls
26 lines (22 loc) · 786 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
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder s = new StringBuilder(br.readLine().toUpperCase());
int[] list = new int[26];
int max=0;char res='?';
for (int i = 0; i < s.length(); i++) {
list[s.charAt(i) - 65]+=1;
if (max < list[s.charAt(i) - 65]) {
max = list[s.charAt(i) - 65];
res = s.charAt(i);
} else if (max == list[s.charAt(i) - 65]) {
res = '?';
}
}
bw.write(res);
bw.flush();bw.close();
}
}