Question
Given an integer, write a function to determine if it is a power of two.
Solution
Result: Accepted Time: 4 ms
Here should be some explanations.
bool isPowerOfTwo(const int n) {
return n > 0 &&n==((-n)&(n));
}
Complexity Analytics
- Time Complexity:
- Space Complexity: