✍쪠와 함께 하루에 30분 이상 시작✨
10809
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr =new int[26];
String word = sc.nextLine();
for(int i = 0; i<arr.length; i++) {
arr[i] = -1; //-1로 초기화
}
for(int i = 0; i < word.length(); i++) { //문자추출
char ch = word.charAt(i);
if(arr[ch-'a'] == -1) { //arr 원소 값이 -1인 경우에만 초기화
arr[ch-'a'] = i;
}
}
for(int i = 0; i<arr.length; i++) {
System.out.print(arr[i]+" ");
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String temp = sc.next();
for( char i = 'a'; i<='z'; i++) {
System.out.print(temp.indexOf(i)+" ");
}
}
}
2675
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int i =0; i<T; i++) {
int R = sc.nextInt();
String S = sc.next();
for (int j = 0; j< S.length(); j++) {
for(int k=0; k<R; k++) {
System.out.print(S.charAt(j));
}
}
System.out.println();
}
}
}