Skip to content

Commit dd511ba

Browse files
committed
[DFS] Rectify time complexity and add a solution to Word Pattern II
1 parent 86355ec commit dd511ba

16 files changed

+78
-30
lines changed

DFS/CombinationSumII.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Question Link: https://leetcode.com/problems/combination-sum-ii/
33
* Primary idea: Classic Depth-first Search
44
*
5-
* Time Complexity: O(n!), Space Complexity: O(2^n - 2)
5+
* Time Complexity: O(n^n), Space Complexity: O(2^n - 2)
66
*
77
*/
88

DFS/CombinationSumIII.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Question Link: https://leetcode.com/problems/combination-sum-iii/
33
* Primary idea: Classic Depth-first Search
44
*
5-
* Time Complexity: O(n!), Space Complexity: O(nCk)
5+
* Time Complexity: O(n^n), Space Complexity: O(nCk)
66
*
77
*/
88

DFS/Combinations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Question Link: https://leetcode.com/problems/combinations/
33
* Primary idea: Classic Depth-first Search, another version of Subsets
44
*
5-
* Time Complexity: O(n!), Space Complexity: O(n)
5+
* Time Complexity: O(n^n), Space Complexity: O(n)
66
*
77
*/
88

DFS/ExpressionAddOperators.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* 1. String cast to Integer will make character loss, e.g. "05" -> 5
88
* 2. Multiplication's priority is higher than addiction
99
*
10-
* Time Complexity: O(n!), Space Complexity: O(n)
10+
* Time Complexity: O(n^n), Space Complexity: O(n)
1111
*
1212
*/
1313

DFS/GeneralizedAbbreviation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Question Link: https://leetcode.com/problems/generalized-abbreviation/
33
* Primary idea: Classic Depth-first Search
44
*
5-
* Time Complexity: O(n!), Space Complexity: O(2^n)
5+
* Time Complexity: O(n^n), Space Complexity: O(2^n)
66
*
77
*/
88

DFS/NQueens.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Primary idea: Classic Depth-first Search, fill out row by row, and check column and
44
* diagnol for each time
55
*
6-
* Time Complexity: O(n!), Space Complexity: O(n^2)
6+
* Time Complexity: O(n^n), Space Complexity: O(n^2)
77
*
88
*/
99

DFS/NQueensII.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Primary idea: Classic Depth-first Search, fill out row by row, and check column and
44
* diagnol for each time, only need to care which column is used
55
*
6-
* Time Complexity: O(n!), Space Complexity: O(n)
6+
* Time Complexity: O(n^n), Space Complexity: O(n)
77
*
88
*/
99

DFS/PalindromePartitioning.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Primary idea: Classic Depth-first Search, use index to track substring,
44
* and move forward to deeper level only if the substring is a palindrome
55
*
6-
* Time Complexity: O(n!), Space Complexity: O(n)
6+
* Time Complexity: O(n^n), Space Complexity: O(n)
77
*
88
*/
99

DFS/Permutations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Question Link: https://leetcode.com/problems/permutations/
33
* Primary idea: Classic Depth-first Search, remember backtracking
44
*
5-
* Time Complexity: O(n!), Space Complexity: O(n)
5+
* Time Complexity: O(n^n), Space Complexity: O(n)
66
*
77
*/
88

DFS/PermutationsII.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Question Link: https://leetcode.com/problems/permutations-ii/
33
* Primary idea: Classic Depth-first Search, adopt last occurrence to avoid dupliates
44
*
5-
* Time Complexity: O(n!), Space Complexity: O(n)
5+
* Time Complexity: O(n^n), Space Complexity: O(n)
66
*
77
*/
88

0 commit comments

Comments
 (0)