Microsoft interview question

How do you do this with LLMs