```
class Solution {
public:
int missingNumber(vector<int>& nums) {
int sum=0;
for(int num:nums)
{
sum+=num;
}
int correctSum = (nums.size()+1)*(nums.size())/2;
return correctSum-sum;
}
};
```