Created
June 4, 2021 12:04
-
-
Save nachiketkanore/271d1bd4587a14ad399acdef9bf10ddd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int go(int i, int j) { | |
if (i == n || j == m) return 0; | |
int &ans = dp[i][j]; | |
if (ans != -1) return ans; | |
ans = 0; | |
int c1 = 0; | |
if (s[i] == t[j]) { | |
c1 = 1 + go(i + 1, j + 1); | |
} | |
int c2 = 0 + go(i + 1, j); | |
int c3 = 0 + go(i, j + 1); | |
return ans = max({c1, c2, c3}); | |
} | |
// max_length = go(0, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment