Capital One interview question

The problem in the coding test have similar difficulty as the easy or medium coding question in LC.