Flipping bits

  • + 0 comments

    I read the problem and had a plan for the implementation but then had to go pick up my daughter at daycare. As I was walking there, I realized that this is just a NOT... doh!!

    Swift:

    func flippingBits(n: Int) -> Int {
        return Int(~UInt32(n))
    }