Pregunta de entrevista de MTX Group

Asked for logic for random problem made by interviewer