Capital One interview question

Two coding questions that I did not pass.