File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change
1
+ //////////////////////////////////////////////////////////////////////////////
2
+ // 1D Dynamic Programming
3
+ // Time: O(n*m)
4
+ // Space: O(m)
5
+ //////////////////////////////////////////////////////////////////////////////
6
+
1
7
/**
2
8
* @param {string } s
3
9
* @param {string } t
@@ -28,6 +34,12 @@ function numDistinct(s, t) {
28
34
return cache [ 0 ] ;
29
35
}
30
36
37
+ //////////////////////////////////////////////////////////////////////////////
38
+ // 2D Dynamic Programming
39
+ // Time: O(n*m)
40
+ // Space: O(n*m)
41
+ //////////////////////////////////////////////////////////////////////////////
42
+
31
43
/**
32
44
* @param {string } s
33
45
* @param {string } t
@@ -63,6 +75,12 @@ function numDistinct(s, t) {
63
75
return cache [ 0 ] [ 0 ] ;
64
76
}
65
77
78
+ //////////////////////////////////////////////////////////////////////////////
79
+ // Depth First Search Recursion With Memoization
80
+ // Time: O(n*m)
81
+ // Space: O(n*m)
82
+ //////////////////////////////////////////////////////////////////////////////
83
+
66
84
/**
67
85
* @param {string } s
68
86
* @param {string } t
You can’t perform that action at this time.
0 commit comments