Question d’entretien chez J.P. Morgan

Solve programming problem and describe approach