J.P. Morgan interview question

Python technical algorithm questions.