Capital One interview question

Plus One LeetCode problem