diff --git a/Change the bits b/Change the bits new file mode 100644 index 000000000..5396373d1 --- /dev/null +++ b/Change the bits @@ -0,0 +1,23 @@ +// { Driver Code Starts +//Initial Template for C++ + +#include +using namespace std; + + // } Driver Code Ends + + +//User function Template for C++ + +class Solution { + public: + vector changeBits(int N) { + // code here + vector vec; + int y = floor(log(N)/log(2))+1; + int a = pow(2,y) - 1; + vec.push_back(abs(a-N)); + vec.push_back(a); + return vec; + } +};