Virtusa Interview Question

A pattern was given and code was asked regarding it