Skip to content

Commit dedca9f

Browse files
authored
Merge pull request #1871 from AlgorithmWithGod/Ukj0ng
[20260202] BOJ / G3 / 크리스 마틴 / 한종욱
2 parents ac4d137 + cc43288 commit dedca9f

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
```

0 commit comments

Comments
 (0)