Power of Two
Total Accepted: 43421 Total Submissions: 130315 Difficulty: Easy
Given an integer, write a function to determine if it is a power of two.
class Solution { public: bool isPowerOfTwo(int n) { long long int m = n; return n==0 ? false : (m&(m-1))==0; } };
Next challenges: (M) Bitwise AND of Numbers Range (M) Perfect Squares (H) Best Meeting Point