Given an array of integers where each number appears a certain number of times except for one unique number, find the number that appears an odd number of times. You must do this efficiently.
You are given a non-empty array of integers. Every number in the array appears an even number of times except for one number which appears an odd number of times. Your task is to find that single number that occurs an odd number of times. For example, in the array [7, 3, 5, 4, 5, 3, 4], the number 7 appears only once, so you should return 7.
A brute force approach would involve iterating through the array and, for each number, iterating through the rest of the array to count how many times it appears. This is like manually checking each item in a large pile to see how many duplicates it has before moving on to the next item.
Work through this problem with AI coaching and get real-time feedback
Practice This Problem