DoorDash Interview Question

What is the complexity of the solution