J.P. Morgan interview question

How did you come ut with that solution?