One line c++ STL


  • 0
    T

    Note: c++14 required.

    class Solution {
    public:
        int singleNumber(vector<int>& nums) {
            return std::accumulate(begin(nums), end(nums), 0, std::bit_xor<int>());
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.