Pregunta de entrevista de Comcast

How would you approach coding this prompt