Pregunta de entrevista de Amazon

Two leetcode questions (check description)