J.P. Morgan Interview Question

logic style math problem