is power of 2

Solutions on MaxInterview for is power of 2 by the best coders in the world

showing results for - "is power of 2"
Francisco
14 Oct 2020
1bool isPowerOfTwo(int n) {
2        
3      return n > 0 && !(n&(n-1));
4    }