MIT Interview Question

How did you solve this problem?