백준 10809번(복습_어려워..)

김경욱·2026년 1월 23일

백준

목록 보기
107/121

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

// Press Shift twice to open the Search Everywhere dialog and type show whitespaces,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

   String text = br.readLine();

   int[] alpha = new int[26];

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

    char[] ch = text.toCharArray();

    for (int i = 0; i < ch.length; i++) {
        int index = ch[i] - 'a';

        if(alpha[index] == -1) {
            alpha[index] = i;
        }
    }

    for (int i : alpha) {
        System.out.print(i+" ");
    }






}

}
다시 봐도 어렵네... ㅜㅜ

0개의 댓글