LeetCode[231] Power of Two
来源:互联网 发布:金税盘开票软件官网 编辑:程序博客网 时间:2024/06/14 02:54
Given an integer, write a function to determine if it is a power of two.
2的幂二进制表示中只有一个1,所以一定满足 n & n - 1 == 0
class Solution {public:bool isPowerOfTwo(int n) {if (n <= 0)return false;return (n & n - 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
- 修改系统 安装和卸载app对话框样式
- Groovy
- 背包问题
- Uplink Port Definition
- java-20160924
- LeetCode[231] Power of Two
- 如何优雅的生活 --工作后
- 一个程序员的顿悟:理想的程序员只比你多了6个一点点
- 字符串数组操作函数
- CSDN
- Android自定义View----时钟/仪表盘的简单实现
- jquery.bind
- 两个有序链表序列的合并
- git忽略文件的正确配置