We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e49fd34 commit ea74351Copy full SHA for ea74351
week14/BOJ_5052(전화번호 목록).java
@@ -0,0 +1,30 @@
1
+import java.io.*;
2
+import java.util.*;
3
+
4
+public class Main {
5
6
+ public static void main(String[] args) throws IOException {
7
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8
+ int t = Integer.parseInt(br.readLine());
9
+ StringBuilder sb = new StringBuilder();
10
+ while(t-- > 0) {
11
+ int n = Integer.parseInt(br.readLine());
12
+ String[] str = new String[n];
13
+ for(int i=0; i<n; i++) {
14
+ str[i] = br.readLine();
15
+ }
16
+ Arrays.sort(str);
17
+ sb.append(check(str) ? "YES" : "NO").append('\n');
18
19
+ System.out.print(sb);
20
21
22
+ public static boolean check(String[] str) {
23
+ for(int i=1; i<str.length; i++) {
24
+ if(str[i].startsWith(str[i-1])) {
25
+ return false;
26
27
28
+ return true;
29
30
+}
0 commit comments