DoorDash interview question

LC Medium problem plus follow ups on edge cases