Given an integer, write a function to determine if it is a power of 2.
class Solution { public: bool isPowerOfTwo(int n) { if(n<=0) return false; else return (n&(n-1))==0; } };
Given an integer, write a function to determine if it is a power of 2.
class Solution { public: bool isPowerOfTwo(int n) { if(n<=0) return false; else return (n&(n-1))==0; } };