1. 程式人生 > >Leetcode 268. Missing Number

Leetcode 268. Missing Number

class Solution {
public:
    int missingNumber(vector<int>& nums) {
        int res = nums.size();
        
        for(int i = 0; i < nums.size(); i++)
        {
            res = res ^ nums[i] ^ i;
        }
        
        return res;
    }
};