C Solution


  • 0
    S

    int findComplement(int num) {
    int a = 0;
    for (int i = 1; i < 32; i++)
    {
    a = num >> i;
    if (a == 0)
    {
    a = i;
    break;
    }
    }
    num = num<<(32-a);
    num = ~num;
    num = num>>(32-a);
    return num;
    }


Log in to reply
 

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