Skip to content

Commit 66eaf7a

Browse files
committed
update readme, cheatsheet, add code comment
1 parent 3896394 commit 66eaf7a

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@
11531153

11541154
| # | Title | Solution | Time | Space | Difficulty | Status | Note|
11551155
|-----|---------------- | --------------- | --------------- | --------------- | ------------- |--------------|-----|
1156-
269 |[Alien Dictionary](https://leetcode.com/problems/alien-dictionary/) | [Python](./leetcode_python/Graph/alien-dictionary.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/Graph/AlienDictionary.java) | | | Hard| Curated Top 75, dfs, bfs, topology sort, `fb`, google, m$, airbnb, uber, amazon | AGAIN******** (4) (not start)
1156+
269 |[Alien Dictionary](https://leetcode.com/problems/alien-dictionary/) | [Python](./leetcode_python/Graph/alien-dictionary.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/Graph/AlienDictionary.java) | | | Hard| Curated Top 75, dfs, bfs, Topologicals sort, `fb`, google, m$, airbnb, uber, amazon | AGAIN******** (4) (not start)
11571157
323| [Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/) | [Python ](./leetcode_python/Graph/number-of-connected-components-in-an-undirected-graph.py), [Java ](./leetcode_java/src/main/java/LeetCodeJava/Graph/NumberOfConnectedComponentsUndirectedGraph.java) | _O(n)_ | _O(n)_| Medium | Curated Top 75, LC 547, 🔒 , dfs, Union Find, `graph`, `linkedin`, `amazon`, fb, google, m$, linkedin| AGAIN************** (5) (MUST)
11581158
959 | [Regions Cut By Slashes](https://leetcode.com/problems/regions-cut-by-slashes/) | [Python](./leetcode_python/Graph/regions-cut-by-slashes.py) | _O(n^2)_| _O(n^2)_| Medium | Union Find |
11591159
1135 | [Connecting Cities With Minimum Cost](https://leetcode.com/problems/connecting-cities-with-minimum-cost/) | [Python](./leetcode_python/Graph/connecting-cities-with-minimum-cost.py) | _O(n^2)_| _O(n^2)_| Medium | union find, Kruskal, prime, graph, amazon | AGAIN (not start)

doc/cheatsheet/topology_sorting.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- LC 444
1919
- Alien Dictionary
2020
- LC 269
21+
- Others
22+
- LC 666, 802
2123

2224
### 0-2) Pattern
2325
```

leetcode_java/src/main/java/LeetCodeJava/Graph/AlienDictionary.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,56 @@
55

66
import java.util.*;
77

8+
/**
9+
* 269. Alien Dictionary
10+
*
11+
* There is a new alien language which uses the latin alphabet.
12+
* However, the order among letters are unknown to you.
13+
* You receive a list of non-empty words from the dictionary,
14+
* where words are sorted lexicographically by the rules of this new language.
15+
* Derive the order of letters in this language.
16+
*
17+
* Example 1:
18+
*
19+
* Input:
20+
* [
21+
* "wrt",
22+
* "wrf",
23+
* "er",
24+
* "ett",
25+
* "rftt"
26+
* ]
27+
*
28+
* Output: "wertf"
29+
* Example 2:
30+
*
31+
* Input:
32+
* [
33+
* "z",
34+
* "x"
35+
* ]
36+
*
37+
* Output: "zx"
38+
* Example 3:
39+
*
40+
* Input:
41+
* [
42+
* "z",
43+
* "x",
44+
* "z"
45+
* ]
46+
*
47+
* Output: ""
48+
*
49+
* Explanation: The order is invalid, so return "".
50+
* Note:
51+
*
52+
* You may assume all letters are in lowercase.
53+
* You may assume that if a is a prefix of b, then a must appear before b in the given dictionary.
54+
* If the order is invalid, return an empty string.
55+
* There may be multiple valid order of letters, return any one of them is fine.
56+
*
57+
*/
858
public class AlienDictionary {
959

1060
// V0

0 commit comments

Comments
 (0)