Ad

Code returns the int that is different from all other ints in an array. Function takes odd size array that contains all the same ints except for 1

int stray(std::vector<int> numbers) {
    
    for(auto n = numbers.begin(); n != numbers.end(); ++n ){
        if (*n != numbers[0]) {
            if (*n != *(n + 1))
                return *n;
            else
                return numbers[0];
        }
    }
};