본문 바로가기
알고리즘 & 자료구조/백준

백준 10809

by 신재권 2021. 7. 13.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main10809 {

	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String S = bf.readLine();
		int[] alpha = new int[26];

		for (int i = 0; i < alpha.length; i++) {
			alpha[i] = -1;
		}

		for (int i = 0; i < S.length(); i++) {
			if (alpha[S.charAt(i) - 97] == -1) {
				alpha[S.charAt(i) - 97] = i;
			}
		}
		for (int i = 0; i < alpha.length; i++) {
			System.out.print(alpha[i] + " ");
		}

	}

}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 1157  (0) 2021.07.14
백준 2675  (0) 2021.07.14
백준 11720  (0) 2021.07.13
백준 11654  (0) 2021.07.10
백준 1065  (0) 2021.07.09