LC 476. Number Complement

public int FindComplement(int num)
{
    int n = ~num;
    int first = num;
    while(first > 0)
    {
        n <<= 1;
        first <<= 1;
    }
    first = num;
    while (first > 0)
    {
        n >>= 1;
        first <<= 1;
    }
    return n;
}
posted @ 2021-12-27 09:51  Destiny130  阅读(18)  评论(0)    收藏  举报