Skip to content

Commit 3081e01

Browse files
remove old code
1 parent 86673fa commit 3081e01

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

HARD/src/hard/AlienDictionary.java

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

0 commit comments

Comments
 (0)