Urban Company interview question

2 leetcode hard questions for me