Pregunta de entrevista de STRV

How would you implement this functionality?