Capital One Interview Question

solving a problem like example