Pregunta de entrevista de Virtusa

A pattern was given and code was asked regarding it