Amazon interview question

Two classical Leetcode Medium questions. Two design problems.