J.P. Morgan Interview Question

Solve programming problem and describe approach