-1

I have two lists

l1 = ['4', '3', '2', '7', '10', '15', '14', '11', '6', '5', 'd']

l2 = ['4', '3', '-2', '-1', 'A', '16', '9', '-12', 'e', '12', '11', '6', '5', 'd', '8',90']

and I want to calculate what is the largest sequence of ordered numbers of l2 that is repeated in l1 and their index in l2.

In this case it would be

result = ['11', '6', '5', 'd']
  • 5
    Are you looking for the [longest common substring](https://en.wikipedia.org/wiki/Longest_common_substring_problem)? – Ry- May 09 '22 at 02:02
  • What have you tried? There's no shortcut here. This is done via nested for loops. – Tim Roberts May 09 '22 at 02:02
  • @TimRoberts: Not if you want it to be fast. – Ry- May 09 '22 at 02:02
  • Does this answer your question? [Find common substring between two strings](https://stackoverflow.com/questions/18715688/find-common-substring-between-two-strings) – thisisrandy May 09 '22 at 02:11

0 Answers0