[leetcode 231]Power of Two
来源:互联网 发布:淘宝店铺评分怎么算 编辑:程序博客网 时间:2024/05/08 02:54
class Solution {public: bool isPowerOfTwo(int n) { /* if(n <= 0) return false; if(n == 1) return true; if(n%2 == 1) return false; return isPowerOfTwo(n/2);*/ return n>0 && !(n&(n-1));//发现可知,2的幂指数数据二进制位都是高位为1,后面为0;减1后为高位为0,后面为1,按位与结果肯定为0; }};
0 0
- leetcode-231 Power of Two
- leetcode 231:Power of Two
- LeetCode 231: Power of Two
- leetcode 231: Power of Two
- leetcode[231]:Power of Two
- Power of Two(leetcode 231)
- leetcode-231-Power of Two
- LeetCode 231 Power of Two
- leetCode #231 Power of Two
- leetcode 231: Power of Two
- [Leetcode]#231 Power of Two
- Leetcode #231 Power of Two
- [LeetCode 231] Power of Two
- [leetcode 231]Power of Two
- 【LeetCode】231Power of Two
- 【LeetCode】231Power of Two
- LeetCode 231 Power of Two
- LeetCode 231:Power of Two
- Binary tree implementation using c++
- [leetcode 110]Balanced Binary Tree
- vs2010下Release版本调试代码设置
- TestQueue测试类
- JAVA IO结构图
- [leetcode 231]Power of Two
- 棋盘问题
- && 中断且 , & 非中断且(与运算) ,|| 中断或 , | 非中断或的区分
- linux mysql 操作命令
- oracle ASM kfod 不太常用的几个参数
- hdu4781Assignment For Princess 构造
- [leetcode 101]Symmetric Tree
- UVa 10114 - Loansome Car Buyer
- 黑马程序员——OC基础---@property @synthesize