Skip to content

Commit f7154b7

Browse files
fix: vla in edit_distance
1 parent 94ca2df commit f7154b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dynamic_programming/edit_distance.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <iostream>
1515
#include <string>
16+
#include <vector>
1617
using namespace std;
1718

1819
int min(int x, int y, int z) { return min(min(x, y), z); }
@@ -46,7 +47,7 @@ int editDist(string str1, string str2, int m, int n) {
4647
*/
4748
int editDistDP(string str1, string str2, int m, int n) {
4849
// Create Table for SubProblems
49-
int dp[m + 1][n + 1];
50+
std::vector<std::vector<int> > dp(m + 1, std::vector<int>(n + 1));
5051

5152
// Fill d[][] in bottom up manner
5253
for (int i = 0; i <= m; i++) {

0 commit comments

Comments
 (0)