-
10809 알파벳 찾기PS/백준 2022. 3. 16. 22:17
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); String inputVal = buf.readLine(); int[] cntArray = new int[26]; for (int i = 0; i < cntArray.length; i++) { cntArray[i] = -1; } for (int i = 0; i < inputVal.length(); i++) { char ch = inputVal.charAt(i); if (cntArray[ch - 97] == -1) { cntArray[ch - 97] = i; } } for (int i = 0; i < cntArray.length; i++) { System.out.print(cntArray[i] + " "); } } }
'PS > 백준' 카테고리의 다른 글
2743 단어 길이 재기 (0) 2022.03.19 10820 문자열 분석 (0) 2022.03.18 10808 알파벳 개수 (0) 2022.03.15 10992 별 찍기 17 (0) 2022.03.14 10991 별 찍기 - 16 (0) 2022.03.13