Single Number

 

CREATED TIME: Feb 02, 2020 12:40 AM UPDATED TIME: Feb 02, 2020 12:59 AM 난이도: Easy

class Solution { public: int singleNumber(vector& nums) { unordered_set s(nums.begin(), nums.end()); int set_sum = accumulate(s.begin(), s.end(), 0); int vector_sum = accumulate(nums.begin(), nums.end(), 0); return set_sum * 2 - vector_sum; } };