Apple interview question

How would you tackle this problem?