Capital One interview question

Standard leetcode style coding question