Pregunta de entrevista de Fast Enterprises

I was asked to do a pseudo code problem.