J.P. Morgan interview question

Some coding challenges using loops and arrays.