본문 바로가기
알고리즘/leetcode

231. Power of Two

by 유이얼 2022. 7. 24.
class Solution {
public:
    bool isPowerOfTwo(int n) {
        return 0 < n && (n & n - 1) == 0;
        //return 0 < n && (n & -n) == n;
    }
};

'알고리즘 > leetcode' 카테고리의 다른 글

190. Reverse Bits  (0) 2022.07.24
191. Number of 1 Bits  (0) 2022.07.24
120. Triangle  (0) 2022.07.22
Subsets II - medium  (0) 2021.08.04
Two Sum - easy  (0) 2021.08.02