-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_10809.java
More file actions
42 lines (33 loc) · 880 Bytes
/
_10809.java
File metadata and controls
42 lines (33 loc) · 880 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
33
34
35
36
37
38
39
40
41
42
package backjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// https://www.acmicpc.net/problem/10809
// 알파벳 찾기
public class _10809 {
public static void main(String[] args) throws IOException {
//memory 11496 runtime 80
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//알파벳 배열생성 후 초기화값 -1
int[] arr = new int[26];
for(int i = 0; i < arr.length; i++) {
arr[i] = -1;
}
String s = br.readLine();
for(int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if(arr[ch - 'a'] == -1) {
arr[ch - 'a'] = i;
}
}
for(int val : arr) { // 배열 출력
System.out.print(val + " ");
}
}
}
/*
input
baekjoon
output
1 0 -1 -1 2 -1 -1 -1 -1 4 3 -1 -1 7 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
*/