DoorDash Interview Question

Leetcode hard with a twist.