Tag Archives: BFS
Serialize and Deserialize Binary Tree – Python 3 (Week 14 – 11)
Time, Space O(n).
Sequence Reconstruction – Python 3 (Week 14 – 10)
Time, Space O(n^2).
Topological Sorting – Python 3 (Week 14 – 06)
Solution 1 BFS Time O(n^2). Space O(n).
Knight Shortest Path – Python 3 (Week 14 – 05)
Time, Space O(nm).
Number of Islands – Python 3 (Week 14 – 04)
Time, Space O(n). n is number of grids
Word Ladder – Python 3 (Week 14 – 03)
Solution 1 分层 Time O(n*l + l^2). Space O(n*l). n is total number of words. l is the max length of word. Solution 2 不分层 Time O(n*l + l^2). Space O(n*l). n is total number of words. l is the max length of word. Solution 3 Bidirectional Breadth First Search Time O(n*l + l^2). Space …
Clone Graph – Python 3 (Week 14 – 02)
Time O(n +m). Space O(n). n is number of nodes, m is number of edges.
Binary Tree Level Order Traversal – Python 3 (Week 14 – 01)
Time, Space: O(n).
Sliding Puzzle II – Python 3 (Week 12 – 14)
Solution I BFS Time O(1). Space O(1).