1.
class Solution { public: int missingNumber(vector<int>& nums) { sort(nums.begin(),nums.end()); for(int i=0;i<nums.size();++i) { if(nums[i]!=i) return i; } return nums.size(); } };
2.
class Solution { public: int missingNumber(vector<int>& nums) { int sum=0,n=nums.size(); for(int &i:nums) sum+=i; return (n*(n+1)/2-sum); } };