Pregunta de entrevista de Fora

Time complexity of solution provided