luoheng
10/6/2019 - 12:13 PM

findComplement

func findComplement(num int) int {
    bit := uint(0)
    for {
        n := 1 << bit
        if n > num {
            return n - 1 - num
        }
        bit++
    }
}