Power of Two
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
写者:zengzy
出处: http://www.cnblogs.com/zengzy
标题有【转】字样的文章从别的地方转过来的,否则为个人学习笔记