J.P. Morgan interview question

logic style math problem