Microsoft Interview Question

How do you do this with LLMs