首页
Python
Java
IOS
Andorid
NodeJS
JavaScript
HTML5
【
leetcode_Power of Two_easy
】的更多相关文章
leetcode_Power of Two_easy
Given an integer, write a function to determine if it is a power of two. 题目意思:推断某个数是否是2的幂. 方法:直接进行bit运算,推断是否这个数二进制位里有且仅有一个1. class Solution { public: bool isPowerOfTwo(int n) { int c=0; while(n!=0) { c+=1&n; if(c>1) return false; n>>=1; } if(…