LeetCode – Missing Number (Java)
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. Java Solution 1 – Math public int missingNumber(int[] nums) { int sum=0; for(int i=0; i<nums.length; i++){ sum+=nums[i]; } int n=nums.length; return … Read more