Skip to content

Commit ea74351

Browse files
committedJul 21, 2024
BOJ_5052 : 전화번호 목록
1 parent e49fd34 commit ea74351

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
 
+30
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)
Please sign in to comment.