Created
June 4, 2021 12:18
-
-
Save nachiketkanore/243a99d7092ebf69e0de746803f86e8d 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
void trace(int i, int j) { | |
if (i == n || j == m) return ; | |
int ans = go(i, j); | |
int c1 = 0; | |
if (s[i] == t[j]) { | |
c1 = 1 + go(i + 1, j + 1); | |
if (c1 == ans) { | |
cout << s[i]; | |
trace(i + 1, j + 1); | |
return; | |
} | |
} | |
int c2 = 0 + go(i + 1, j); | |
if (c2 == ans) { | |
trace(i + 1, j); | |
return; | |
} | |
int c3 = 0 + go(i, j + 1); | |
if (c3 == ans) { | |
trace(i, j + 1); | |
return; | |
} | |
} | |
// call trace(0, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment