DoorDash interview question

Basic algorithmic stuff.