-
Notifications
You must be signed in to change notification settings - Fork 0
231_PowerofTwo
a920604a edited this page Apr 14, 2023
·
1 revision
title: 231. Power of Two
class Solution {
public:
bool isPowerOfTwo(int n) {
if(n<=0) return false;
return (n&(n-1)) ==0;
}
};
- time complexity
O(1)
- space complexity
O(1)
footer