DoorDash Interview Question

A Dynamic Problem that requires returning the final sequence.