Capital One interview question

For the programming question they asked me a LeetCode question of difficulty: Easy