본문 바로가기
Problem Solving

[백준/BOJ] 10809 알파벳 찾기 JAVA

by JYHAN 2020. 7. 6.

[백준/BOJ] 10809 알파벳 찾기 JAVA

 

import java.util.Scanner;

public class BOJ_10809_알파벳찾기 {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 String word = sc.nextLine();
		 int[] words = new int[26];
		 
		 for(int i=0; i<words.length; i++) {
			 words[i] = -1;
		 }
		 for(int i=0; i<word.length(); i++) {
			 int num = (word.charAt(i) - '0')-49;
			 if(words[num]==-1) words[num] = i;
		 }
		 for(int i=0; i<words.length; i++) {
			 System.out.printf("%d ", words[i]);
		 }
	}
}

댓글