My c code 4ms without loops

  • 0
    uint32_t reverseBits(uint32_t n) {
        int Table[]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
        int a1=Table[0xf&n];
        int a2=Table[(0xf0&n)>>4];
        int a3=Table[(0xf00&n)>>8];
        int a4=Table[(0xf000&n)>>12];
        int a5=Table[(0xf0000&n)>>16];
        int a6=Table[(0xf00000&n)>>20];
        int a7=Table[(0xf000000&n)>>24];
        int a8=Table[(0xf0000000&n)>>28];
        return (a1<<28)+(a2<<24)+(a3<<20)+(a4<<16)+(a5<<12)+(a6<<8)+(a7<<4)+a8;


Log in to reply

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