

-Code
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
public class BOJ18766 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int testCase = sc.nextInt();
for (int i = 0; i < testCase; i++) {
int n = sc.nextInt();
String[] before = new String[n];
String[] after = new String[n];
for (int j = 0; j < n; j++) before[j] = sc.next();
for (int j = 0; j < n; j++) after[j] = sc.next();
// 2개의 배열 정렬
Arrays.sort(before);
Arrays.sort(after);
// 정렬한 배열이 같으면 치터가 아님
System.out.println(Arrays.equals(before, after) ? "NOT CHEATER" : "CHEATER");
}
sc.close();
}
}'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
| [LeetCode/Java] Build an Array With Stack Operations (0) | 2025.11.26 |
|---|---|
| [백준/Java] 34758번 KUPC에 어서 오세요 (0) | 2025.11.26 |
| [백준/Java] 31432번 소수가 아닌 수 3 (0) | 2025.11.24 |
| [LeetCode/Java] Find All Numbers Disappeared in an Array (0) | 2025.11.24 |
| [LeetCode/Java] How Many Numbers Are Smaller Than the Current Number (0) | 2025.11.24 |