Skip to content

Commit 4623e05

Browse files
committed
[Bronze II] Title: 알파벳 찾기, Time: 152 ms, Memory: 16008 KB -BaekjoonHub
1 parent e0dfa99 commit 4623e05

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# [Bronze II] 알파벳 찾기 - 10809
2+
3+
[문제 링크](https://www.acmicpc.net/problem/10809)
4+
5+
### 성능 요약
6+
7+
메모리: 16008 KB, 시간: 152 ms
8+
9+
### 분류
10+
11+
구현, 문자열
12+
13+
### 제출 일자
14+
15+
2024년 3월 27일 23:01:12
16+
17+
### 문제 설명
18+
19+
<p>알파벳 소문자로만 이루어진 단어 S가 주어진다. 각각의 알파벳에 대해서, 단어에 포함되어 있는 경우에는 처음 등장하는 위치를, 포함되어 있지 않은 경우에는 -1을 출력하는 프로그램을 작성하시오.</p>
20+
21+
### 입력
22+
23+
<p>첫째 줄에 단어 S가 주어진다. 단어의 길이는 100을 넘지 않으며, 알파벳 소문자로만 이루어져 있다.</p>
24+
25+
### 출력
26+
27+
<p>각각의 알파벳에 대해서, a가 처음 등장하는 위치, b가 처음 등장하는 위치, ... z가 처음 등장하는 위치를 공백으로 구분해서 출력한다.</p>
28+
29+
<p>만약, 어떤 알파벳이 단어에 포함되어 있지 않다면 -1을 출력한다. 단어의 첫 번째 글자는 0번째 위치이고, 두 번째 글자는 1번째 위치이다.</p>
30+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.io.*;
2+
import java.util.*;
3+
public class Main {
4+
public static void main(String[] args) throws IOException {
5+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
6+
String str = br.readLine();
7+
int[] idx = new int[26];
8+
Arrays.fill(idx, -1);
9+
for(char c : str.toCharArray()) {
10+
idx[c-97] = str.indexOf(c);
11+
}
12+
Arrays.stream(idx).forEach(r -> System.out.print(r + " "));
13+
}
14+
}

0 commit comments

Comments
 (0)