CG Infinity interview question

Q. Coding question, print pattern