Search
 
SCRIPT & CODE EXAMPLE
 

CPP

is power of 2

bool isPowerOfTwo(int n) {
        
      return n > 0 && !(n&(n-1));
    }
Comment

power of two

Input: n = 3
Output: false
Comment

number is a power of 2

bool IsPowerOfTwo(ulong x)
{
    return (x != 0) && ((x & (x - 1)) == 0);
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to reverse a vector 
Cpp :: initialize vector of vector c++ 
Cpp :: vector::insert 
Cpp :: c++ string size 
Cpp :: how to initialize a vector of pairs in c++ 
Cpp :: To Lower Case leetcode solution in c++ 
Cpp :: c++ initialize vector of vector with size 
Cpp :: how to check a number in string 
Cpp :: push local branch to another remote branch 
Cpp :: c++ vector resize 
Cpp :: c++ ternary operator 
Cpp :: c++ hashmaps 
Cpp :: function in c++ 
Cpp :: c++ get the line which call a function 
Cpp :: cpp float 
Cpp :: how to find something in a string in c++ 
Cpp :: power of a number 
Cpp :: c++ erase remove 
Cpp :: C++ std::optional 
Cpp :: list in c++ 
Cpp :: accumulate() in c++ 
Cpp :: how to remove maximum number of characters in c++ cin,ignore 
Cpp :: insert element in array c++ 
Cpp :: C++ Nested if...else 
Cpp :: what do you mean by smallest anagram of a string 
Cpp :: how to grab numbers from string in cpp 
Cpp :: how to copy vector to another vector in c++ 
Cpp :: how to convert hexadecimal to decimal in c++ 
Cpp :: What is a ~ in c++ 
Cpp :: string concatenation operator overloading c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =