Pregunta de entrevista de Amazon

Coding interview had 2 problems with dsa.