Pregunta de entrevista de Deloitte

They asked me to write a quick algorithm based on a given statement