-
[백준] 2675번 문자열 반복 - 브론즈 2코딩 테스트 2023. 1. 17. 19:26
입력
- 테스트 케이스 수
- (테스트 케이스 수 만큼의) 반복 횟수, 문자열
출력
- 테스트 결과
문자열 문제!
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class B2675 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int num = Integer.parseInt(br.readLine()); //테스트 케이스 수 int[] re = new int[num]; String[][] arr = new String[num][]; String[] res = new String[num]; for(int i = 0; i < num; i++) { String[] tmp = br.readLine().split(" "); re[i] = Integer.parseInt(tmp[0]); //반복 횟수 arr[i] = tmp[1].split(""); res[i] = ""; //null값 출력 방지 for (int j = 0; j < arr[i].length; j ++) for (int k = 0; k < re[i]; k++) res[i] += arr[i][j]; } for (String tmp : res) System.out.println(tmp); } }
이런 문자열 문제는 파이썬을 쓰는게 훨~씬 간단할텐데,,
그리고 람다를 좀 연습해야 할 것 같다..!
'코딩 테스트' 카테고리의 다른 글
Do it! 알고리즘 코딩 테스트 - 자바 편 (0) 2023.01.20 [백준] 1929번 소수 구하기 (0) 2023.01.19 배열 형변환 (Stream) (0) 2023.01.17 [백준] 2563번 색종이 - 실버5 (0) 2023.01.17 [백준] 20115번 에너지 드링크(그리디) - 실버3 (0) 2023.01.15