欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

LeetCode-Hot Topic 100: 136.只出现一次的数字--代码和注释

最编程 2024-04-16 16:54:42
...
func singleNumber(nums []int) int {
    res := 0 
    for _, num  := range nums{
        res ^= num  // 对数组中的所有数字进行异或运算
    }
    return res
}