Pregunta de entrevista de Google

Two leetcode medium questions, each roughly 40 mins