mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-04 16:12:47 +08:00
10 lines
151 B
Go
10 lines
151 B
Go
package leetcode
|
|
|
|
func missingNumber(nums []int) int {
|
|
xor, i := 0, 0
|
|
for i = 0; i < len(nums); i++ {
|
|
xor = xor ^ i ^ nums[i]
|
|
}
|
|
return xor ^ i
|
|
}
|