File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ ```
2+ import java.io.*;
3+ import java.util.*;
4+
5+ public class Main {
6+ private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+ private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+ private static Map<Character, Integer> map;
9+ private static char answer;
10+ private static int N, count;
11+
12+ public static void main(String[] args) throws IOException {
13+ init();
14+
15+ bw.write(count + "\n");
16+ for (int i = 0; i < N; i++) {
17+ bw.write(answer + "");
18+ }
19+ bw.flush();
20+ bw.close();
21+ br.close();
22+ }
23+
24+ private static void init() throws IOException {
25+ N = Integer.parseInt(br.readLine());
26+ count = N;
27+ char[] input = br.readLine().toCharArray();
28+
29+ map = new HashMap<>();
30+
31+ map.put('A', 0);
32+ map.put('C', 0);
33+ map.put('G', 0);
34+ map.put('T', 0);
35+ for (int i = 0; i < N; i++) {
36+ map.put(input[i], map.get(input[i])+1);
37+ }
38+
39+ for (char key : map.keySet()) {
40+ if (count > map.get(key)) {
41+ count = map.get(key);
42+ answer = key;
43+ }
44+ }
45+ }
46+ }
47+ ```
You can’t perform that action at this time.
0 commit comments