[백준/Java] 10809 : 알파벳 찾기

SEOP·2023년 6월 20일
0
post-custom-banner

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int[] arr = new int[26];

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

        String S = br.readLine();
        for(int j = 0 ; j < S.length() ; j++){
            char c = S.charAt(j);

            if(arr[c -'a'] == -1){
                arr[c-'a'] = j;
            }
        }

        for(int k :arr){
            bw.write(k+" ");
        }

        bw.flush();
        bw.close();
    }
}
profile
응애 나 애기 개발자
post-custom-banner

0개의 댓글