Pregunta de entrevista de Informatica

For the previous question how will u decrease the complexity ?