2017.9.11
感觉并没有啥意思啊这题,还是我误解了这题的真谛?
public class Solution {
/**
* @param nums an array containing n + 1 integers which is between 1 and n
* @return the duplicate one
*/
public int findDuplicate(int[] nums) {
// Write your code here
Arrays.sort(nums);
for(int i = 0;i < nums.length-1;i++){
if(nums[i] == nums[i+1]){
return nums[i];
}
}
return 0;
}
}