Golang | Leetcode Golang题解之第137题只出现一次的数字II

作者 : admin 本文共98个字,预计阅读时间需要1分钟 发布时间: 2024-06-10 共2人阅读

题目:

Golang | Leetcode Golang题解之第137题只出现一次的数字II插图

题解

func singleNumber(nums []int) int {
    a, b := 0, 0
    for _, num := range nums {
        b = (b ^ num) &^ a
        a = (a ^ num) &^ b
    }
    return b
}
本站无任何商业行为
个人在线分享 » Golang | Leetcode Golang题解之第137题只出现一次的数字II
E-->