MathTop

longest_common_subsequence 函数

返回两个字符串共有的一个最长有序子序列,字符不必相邻。

语法

  • LongestCommonSubSequence(text1, text2)
  • StringTools:-LongestCommonSubSequence(text1, text2)
  • longest_common_subsequence(text1, text2)

参数与选项

text1第一个文本值。
text2第二个文本值。

示例

  1. 有序公共子序列LongestCommonSubSequence('abcdef', 'azced')返回 acd。
  2. 包调用形式StringTools:-LongestCommonSubSequence('ABCBDAB', 'BDCABA')返回 BCBA。