-
-
Save ucarion/0513b84bd3981d34cb88 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
fn backtrack<'a, T>(&self, a: &'a [T], b: &'a [T], i: usize, j: usize) -> Vec<&'a T> | |
where T: Eq { | |
if i == 0 || j == 0 { | |
vec![] | |
} else if a[i] == b[j] { | |
let mut prefix_lcs = self.backtrack(a, b, i - 1, j - 1); | |
prefix_lcs.push(&a[i]); | |
prefix_lcs | |
} else { | |
if self.lengths[i][j - 1] > self.lengths[i - 1][j] { | |
self.backtrack(a, b, i, j - 1) | |
} else { | |
self.backtrack(a, b, i - 1, j) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment