Skip to content

Commit

Permalink
[DFS] Rectify time and space complexity of Word Search
Browse files Browse the repository at this point in the history
  • Loading branch information
soapyigu committed Jun 20, 2018
1 parent 9a565a4 commit 10a90cd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DFS/WordSearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Question Link: https://leetcode.com/problems/word-search/
* Primary idea: Classic Depth-first Search, go up, down, left, right four directions
*
* Time Complexity: O((n^2)!), Space Complexity: O(n^2)
* Time Complexity: O(mn * 4^(k - 1)), m and n stand for width and height of matrix, k is the word size, Space Complexity: O(mn)
*
*/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
[Is Graph Bipartite](https://leetcode.com/problems/is-graph-bipartite/)| [Swift](./DFS/IsGraphBipartite.swift)| Medium| O(n)| O(n)|
[Number of Islands](https://leetcode.com/problems/number-of-islands/)| [Swift](./DFS/NumberofIslands.swift)| Medium| O((mn)^2)| O(1)|
[Walls and Gates](https://leetcode.com/problems/walls-and-gates/)| [Swift](./DFS/WallsGates.swift)| Medium| O(n!)| O(2^n)|
[Word Search](https://leetcode.com/problems/word-search/)| [Swift](./DFS/WordSearch.swift)| Medium| O((n^2)!)| O(n^2)|
[Word Search](https://leetcode.com/problems/word-search/)| [Swift](./DFS/WordSearch.swift)| Medium| O((mn * 4 ^ (k - 1))| O(mn)|
[Word Search II](https://leetcode.com/problems/word-search-ii/)| [Swift](./DFS/WordSearchII.swift)| Hard| O(((mn)^2))| O(n^2)|
[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word-data-structure-design/)| [Swift](./DFS/WordDictionary.swift)| Medium| O(n)| O(n)|
[N-Queens](https://leetcode.com/problems/n-queens/)| [Swift](./DFS/NQueens.swift)| Hard| O((n!))| O(n^2)|
Expand Down

0 comments on commit 10a90cd

Please sign in to comment.