You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Concept: In the recursive logic, we set the base case too `if(i<0)` and if(j<0) but we can’t set the dp array’s index to -1. Therefore a hack for this issue is to shift every index by 1 towards the right.
113
+
Concept: In the recursive logic, we set the base case to `if(i<0)` and `if(j<0)` but we can’t set the dp array’s index to -1. Therefore a hack for this issue is to shift every index by 1 towards the right.
114
114
115
115
#### Algorithm
116
116
@@ -160,7 +160,7 @@ int editDistance(string& S1, string& S2) {
160
160
161
161
### Complexity Analysis
162
162
163
-
-**Time complexity**: O(N*M)
163
+
-**Time complexity**: $O(N \times M)$
164
164
Reason: There are two nested loops
165
-
-**Space complexity**: O(N*M)
165
+
-**Space complexity**: $O(N \times M)$
166
166
Reason: We are using an external array of size ‘N*M’. Stack Space is eliminated.
0 commit comments