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-java21 Show documentation
Show all versions of leetcode-in-java21 Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
package g0201_0300.s0268_missing_number;
// #Easy #Array #Hash_Table #Math #Sorting #Binary_Search #Bit_Manipulation
// #2022_07_05_Time_1_ms_(72.07%)_Space_50.6_MB_(76.88%)
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;
}
}