[알고리즘/백준] 10809 알파벳 찾기(자바)

[알고리즘/백준] 10809 알파벳 찾기(자바)

문제

https://www.acmicpc.net/problem/10809

풀이 코드

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] answer = new int[26]; Arrays.fill(answer, -1); String s = br.readLine(); for (int i = 0; i < s.length(); i++) { if (answer[s.charAt(i) - 97] == -1) { answer[s.charAt(i) - 97] = i; } } for (int i : answer) { System.out.print(i + " "); } } }

728x90

from http://developer-hm.tistory.com/156 by ccl(A) rewrite - 2021-09-20 02:01:37