DoorDash Interview Question

2 hard questions from leetcode