Given an array contains N numbers of 0 .. N, find which number doesn't exist in the array.
public class Solution { /** * @param nums: an array of integers * @return: an integer */ public int findMissing(int[] nums) { // write your code here if(nums == null || nums.length == 0) return 0; int sum = 0; for(int i = 0; i < nums.length; i++){ sum += nums[i]; } int N = nums.length; return N * (N + 1) / 2 - sum; }}