You are viewing a single comment's thread. Return to all comments →
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; }
Seems like cookies are disabled on this browser, please enable them to open this website
Lonely Integer
You are viewing a single comment's thread. Return to all 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; }