Pregunta de entrevista de Amazon

Two classical Leetcode Medium questions. Two design problems.