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];
}
}
};
// TODO: Replace examples and use TDD development by writing your own tests
Describe(array)
{
It(should_do_something)
{
Assert::That(stray({0,1,1,1}), Equals(0));
}
};