标签:
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n
, find the one that is missing from the array.
For example,
Given nums = [0, 1, 3]
return 2
.
代码如下:
1 public class Solution { 2 public int missingNumber(int[] nums) { 3 Arrays.sort(nums); 4 for(int i=0;i<nums.length;i++) 5 { 6 if(nums[i]!=i) 7 return i; 8 } 9 return nums.length; 10 } 11 }
标签:
原文地址:http://www.cnblogs.com/ghuosaao/p/5442250.html