Lonely Integer

  • + 0 comments

    include

    include // For std::accumulate

    include

    int lonelyinteger(const std::vector& nums) { return std::accumulate(nums.begin(), nums.end(), 0, std::bit_xor()); }

    int main() { std::vector nums = {1, 1, 2, 2, 3}; // Example input std::cout << lonelyinteger(nums) << std::endl; return 0; }