Pregunta de entrevista de Amazon

Leet code Medium problem and Hard Problem