Pregunta de entrevista de Amazon

two coding questions of difficulty level leetcode medium