Following is my solution for the missing number. But pass only 16 test cases

Can anyone tell me why ?

```
class Solution {
public:
int missingNumber(vector<int>& nums) {
int stepValue = 1;
if (nums[0] != 0)
{
return 0;
}
int currentNumber = nums[0];
for (int i = 1 ; i < nums.size(); i++)
{
if (currentNumber + stepValue < nums[i])
return currentNumber + stepValue;
else
currentNumber = nums[i];
}
}
};
```