File tree 1 file changed +1
-9
lines changed
1 file changed +1
-9
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,13 @@ public class AlienDictionary {
12
12
* And all code on the Discuss board fail by this test case.*/
13
13
public static String alienOrder (String [] words ) {
14
14
Set <String > orders = new HashSet ();
15
- Set <Character > orderChar = new HashSet ();
16
15
for (int i = 0 ; i < words .length -1 ; i ++){
17
16
for (int j = 0 ; j < Math .min (words [i ].length (), words [i +1 ].length ());j ++){
18
17
if (words [i ].charAt (j ) != words [i +1 ].charAt (j )){
19
18
String order = "" + words [i ].charAt (j ) + words [i +1 ].charAt (j );
20
19
String reverseOrder = "" + words [i +1 ].charAt (j ) + words [i ].charAt (j );
21
20
if (!orders .contains (order )) {
22
- orders .add (order );
23
- orderChar .add (words [i ].charAt (j ));
24
- orderChar .add (words [i +1 ].charAt (j ));
25
- }
21
+ orders .add (order ); }
26
22
if (orders .contains (reverseOrder )) return "" ;
27
23
break ;
28
24
}
@@ -38,10 +34,6 @@ public static String alienOrder(String[] words) {
38
34
}
39
35
}
40
36
41
- for (char c : appearedLetters ){
42
- if (!orderChar .contains (c )) return "" ;
43
- }
44
-
45
37
int [] indegree = new int [26 ];
46
38
for (String order : orders ){
47
39
indegree [order .charAt (1 ) - 'a' ]++;
You can’t perform that action at this time.
0 commit comments