#include class Solution { public: bool isPowerOfTwo(int n) { if (n <= 0) return false; std::bitset bits(n); return bits.count() == 1; } };