Pergunta de entrevista da empresa MTX Group

Asked for logic for random problem made by interviewer