Question d’entretien chez J.P. Morgan

Two different code solutions how would you solve that conflict?