Pregunta de entrevista de Amazon

Medium difficulty leet code questions.