@@ -12,17 +12,13 @@ public class AlienDictionary {
1212 * And all code on the Discuss board fail by this test case.*/
1313public static String alienOrder (String []words ) {
1414Set <String >orders =new HashSet ();
15- Set <Character >orderChar =new HashSet ();
1615for (int i =0 ;i <words .length -1 ;i ++){
1716for (int j =0 ;j <Math .min (words [i ].length (),words [i +1 ].length ());j ++){
1817if (words [i ].charAt (j ) !=words [i +1 ].charAt (j )){
1918String order ="" +words [i ].charAt (j ) +words [i +1 ].charAt (j );
2019String reverseOrder ="" +words [i +1 ].charAt (j ) +words [i ].charAt (j );
2120if (!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 ); }
2622if (orders .contains (reverseOrder ))return "" ;
2723break ;
2824 }
@@ -38,10 +34,6 @@ public static String alienOrder(String[] words) {
3834 }
3935 }
4036
41- for (char c :appearedLetters ){
42- if (!orderChar .contains (c ))return "" ;
43- }
44-
4537int []indegree =new int [26 ];
4638for (String order :orders ){
4739indegree [order .charAt (1 ) -'a' ]++;