Morgan Stanley Interview Question

Brain teaser, algorithm, sde