class Solution {

public int missingNumber(int[] nums) {

Arrays.sort(nums);

int start = 0;

int end = nums.length - 1;

while(start + 1 < end) {

int mid = start + (end - start) / 2;

if (nums[mid] == mid) {

start = mid;

} else {

end = mid;

}

}

if (nums[end] == end) {

return end + 1;

}

if (nums[start] > start) {

return start;

}else {

return start + 1;

}

}

}