Domanda di colloquio di Google

Two leetcode medium questions, each roughly 40 mins