Pregunta de entrevista de Greek Ministry of Education

Question regarding the computational complexity of sample algorithm