J.P. Morgan interview question

Solve programming problem and describe approach