824. Single Number IV

class Solution { public: /** * @param nums: The number array * @return: Return the single number */ int getSingleNumber(vector<int> &nums) { // Write your code here int sizeN = nums.size(); if(sizeN == 0){ return -1; } int res = nums[0]; for(int i = 1; i < sizeN; i++){ res ^= nums[i]; } return res; } };

Comments

Popular posts from this blog

1386. Cinema Seat Allocation

1395. The Barycentre Of The Trees

Amazon OA 763. Partition Labels