re: Coding Puzzles: Week of 4/8 VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Thanks for this! I don't really know C++, but I figured I'd give it a shot: int stray(std::vector<int> numbers) { int n1, n2, n3; ...
 

@laurieontech did something really cool in JS with a bitwise XOR (her answer is above), so I figured I'd update this C++ answer with a bitwise XOR since I love it!

int stray(std::vector<int> numbers) {
    int r = numbers[0];
    for (int i = 1; i < numbers.size(); i++)
    {
        r ^= numbers[i];
    }
    return r;
};
code of conduct - report abuse