J.P. Morgan interview question

Question related to solve given problem