We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 175a7a7 commit 99f48c6Copy full SHA for 99f48c6
suyeun84/202507/05 BOJ G4 고냥이.md
@@ -0,0 +1,25 @@
1
+```java
2
+import java.io.*;
3
+
4
+public class boj16472 {
5
+ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
6
7
+ public static void main(String[] args) throws Exception {
8
+ int N = Integer.parseInt(br.readLine());
9
+ String input = br.readLine();
10
+ int[] alpha = new int[26];
11
+ int cnt = 0, answer = 0, start = 0, end = -1;
12
13
+ while (++end < input.length()) {
14
+ if (alpha[input.charAt(end) - 'a']++ == 0) cnt++;
15
16
+ while (N < cnt) {
17
+ if (--alpha[input.charAt(start++) - 'a'] == 0) cnt--;
18
+ }
19
20
+ answer = Math.max(answer, end - start + 1);
21
22
+ System.out.println(answer);
23
24
+}
25
+```
0 commit comments