코테준비 - Power of Two

정상화·2023년 2월 26일

LeetCode

목록 보기
201/222

Power of Two


class Solution {
public:
    bool isPowerOfTwo(int n) {
//        cout << "log=" << log2(n) << "\n";
        if(n<=0) return false;
        int exp = log2(n);
        return n == pow(2, exp);
    }
};
profile
백엔드 희망

0개의 댓글