I have two arrays, searchand target. I want to find the longest sequence of elements searchthat starts from the beginning searchand which also appears in the same order in a row in target. Then I want to return a copy targetwith deleted items.
Here are some examples:
search = [4, "apple", 6, "turnip"]
target = [5, "apple", 4, "orange"]
=> [5, "apple", "orange"]
search = [4, "apple", 6, "turnip"]
target = [5, "apple", 4, "apple"]
=> [5, "apple"]
search = [4, "apple", 6, "turnip"]
target = [5, "apple", 6, 7]
=> [5, "apple", 6, 7]
What is the most concise way to perform this check?
source
share