The question description is all wrong. if there is no missing number, it wants to to return the n+1 number. Here is the solution.

```
class Solution {
public int missingNumber(int[] nums) {
Arrays.sort(nums);
for(int i=0;i<nums.length;i++)
{
if(i!=nums[i])
{
return i;
}
}
return nums.length;
}
}
```