-
[1] 문제
[2] CODE
import java.util.*; public class Main { public static void main(String[] args) throws Exception{ Scanner scan = new Scanner(System.in); int [] arr = new int [26]; for ( int i = 0; i<arr.length; i++) { arr[i] = -1; } String S = scan.nextLine(); for ( int i = 0; i < S.length(); i++) { char ch = S.charAt(i); if(arr[ch-'a'] == -1 ) { arr[ch-'a'] = i; } } for ( int temp:arr) { System.out.println(temp + ""); } } }
'PS > 백준' 카테고리의 다른 글
[백준_1946] 신입사원 (Greedy) (0) 2021.01.05 [백준_1541] 잃어버린 괄호 ( Greedy ) (0) 2021.01.05 [백준_2839] 설탕 배달 ( Greedy ) (0) 2021.01.05 [백준_2798] 블랙잭 (0) 2020.12.24 [백준_2309] 일곱난쟁이 (0) 2020.12.24 댓글