Fivestars interview question

variant of largest common subsequence