J.P. Morgan interview question

coding using data structures