File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments