Pergunta de entrevista da empresa Deloitte

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