Pregunta de entrevista de Anonymous

Coding questions and they asked to optimise the code