As reported: DoorDash tech screen (USA, 2025).
Two dashers who are best friends can each complete up to n ordered pickups in a day, given as two arrays of merchant names, dasher1 and dasher2. They want to ride in one car and do the same pickups together, keeping each dasher's original order. Both go left to right through their own list and may skip jobs: for example, they can do walmart and then mcdonalds together, giving up the jobs between them and the ones before their respective walmarts.
Return the longest sequence of pickups they can complete together.
Example 1
dasher1 = ["chillis", "albertsons", "walmart", "albertsons", "chillis", "mcdonalds", "burger king"]
dasher2 = ["chillis", "walmart", "chillis", "albertsons", "burger king", "applebees", "mcdonalds"]
Output: 4
For example ["chillis", "walmart", "albertsons", "burger king"] or ["chillis", "walmart", "chillis", "mcdonalds"] — either is accepted.
Example 2
dasher1 = ["wendys", "safeway"]
dasher2 = ["costco", "target"]
Output: 0
They share no pickup: return [].
Clarifications
- If several sequences have the maximum length, return any of them.
- Merchant names are compared exactly; the same merchant can appear several times in a list.
Constraints: 1 ≤ n ≤ 1000 (dasher1.length == dasher2.length == n); names are 1 to 20 lowercase letters and spaces.
Code runner format: one JSON value per line: dasher1, then dasher2. Implement longestSharedPickups(dasher1, dasher2) returning the list of merchant names. The harness checks that your list is a sequence both dashers can do in order and prints its length (the expected output is the maximum length).