Capital One interview question

Coding question was asked on the test