g0201_0300.s0268_missing_number.Solution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
package g0201_0300.s0268_missing_number;
// #Easy #Top_Interview_Questions #Array #Hash_Table #Math #Sorting #Bit_Manipulation
public class Solution {
public int missingNumber(int[] nums) {
int a = nums.length;
for (int i = 0; i < nums.length; i++) {
a ^= i;
a ^= nums[i];
}
return a;
}
}