Microsoft interview question

How can you solve this challenge?