Pregunta de entrevista de Capital One

Coding question was asked on the test