Flipping bits

You will be given a list of 32-bit unsigned integers. Flip all the bits ( and ) and return the result as an unsigned integer.

Example:

Input:  n = 1
Output: 4294967294

Approach

C++

#include <bits/stdc++.h>
using namespace std;

unsigned flippingBits(unsigned n)
{
    return (~n);
}
int main()
{

    unsigned n = 1;
    cout << flippingBits(n);
    return 0;
}


No comments:

Post a Comment