231_PowerofTwo - a920604a/leetcode GitHub Wiki
title: 231. Power of Two
- Bit Manipulation
categories: leetcode
comments: false
tags:problem
solution
class Solution {
public:
bool isPowerOfTwo(int n) {
if(n<=0) return false;
return (n&(n-1)) ==0;
}
};
analysis
- time complexity
O(1)
- space complexity
O(1)