DoorDash interview question

Two Lc medium on leetcode