Two dashers (who happen to be best buds) can complete upto n possible ordered pickups on a certain day. These pickups are represented by two arrays of length n, one for each dasher. A pickup is represented by name of merchant, for example “chillis” or “albertons”.
We could have the following rwo arrays that represent the pickup jobs for the two dashers:
dasher1_pickups = [“chillis”, “albertsons”, “walmart”, “albtertsons”, “chillis”, “mcdonalds”, “burger king”]
Dasher2_pickups = [“chillis”, “walmart”, “chillis”, “albertsons”, “burger king”, “applebees”, “mcdonalds”]
These two dasher buddies choose to dash in one of the car and want to complete the same pickup jobs together while respecting the original ordering. At the same time however, they want to complete as many deliveries as possible to maximize their payout.
What is the longest sequence of pickups that these two dashers can complete together?
Note: The dashers must complete the deliveries in the above order (from left to right), but are allowed to skip pickup jobs. For example, it is totally okay for dashers to go from “walmart” to “mcdonalds” together, but they now forfeit the right to complete any delivery between those two merchants, or complete any delivery before their respective “walmarts”