Domanda di colloquio di Amazon

Two classical Leetcode Medium questions. Two design problems.