Pergunta de entrevista da empresa Capital One

Coding question was asked on the test