bitwise solution in golang


  • 0
    G
    func singleNumber(nums []int) int {
        counto,countt,countos,countts := 0,0,0,0
        
        for _,v := range nums{
            countos = (v &^ counto &^ countt) | (counto &^ v)
            countts = (v & counto) | (countt &^ v)
            counto = countos
            countt = countts
        }
        
        return counto
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.