DoorDash interview question

2 hard questions from leetcode