Capital One interview question

Algorithm based questions in Python