Java: two lines use bit manipulation


  • 0
    F
    public int reverseBits(int n) {
            for (int i = 0; i < 16; i++) if ((n >> i & 1) != (n >> (31 - i) & 1)) n ^= 1 << i ^ 1 << (31 - i);
            return n;
    }
    

Log in to reply
 

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