Pregunta de entrevista de Amazon

Leet code type of problems with hard level.