LongestCommonSequence

LongestCommonSequence[s1,s2]
finds the longest sequence of contiguous or disjoint elements common to the strings or lists and .

Details and OptionsDetails and Options

  • LongestCommonSequence returns the longest common sequence with disjoint pieces concatenated.
  • If there are several common subsequences of the same length, LongestCommonSequence returns the one that begins earliest in .
  • For strings, setting the option IgnoreCase->True makes LongestCommonSequence treat lowercase and uppercase letters as equivalent, and return the form of common sequence that occurs in .

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

Find the longest noncontiguous sequence common to two strings:

In[1]:=
Click for copyable input
Out[1]=

Find the longest noncontiguous sequence common to two lists:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 2008
(7.0)
Translate this page: