*LeetCode-Power of Two
来源:互联网 发布:excel会计记账软件 编辑:程序博客网 时间:2024/06/06 19:34
首先除法的要注意corner case 0,1之类的
然后就是另一个方法是数bit 1 的个数 2的power只能有一个1
public class Solution { public boolean isPowerOfTwo(int n) { return n>0 && Integer.bitCount(n) == 1; }}
return ((n & (n-1))==0 && n>0);
0 0
- [LeetCode] Power of Two
- 【LeetCode】Power of Two
- [Leetcode]Power of Two
- [leetCode] Power of Two
- leetcode --Power of Two
- leetcode: Power of Two
- LeetCode Power of Two
- [LeetCode] Power of Two
- LeetCode Power of Two
- [leetcode] Power of Two
- [Leetcode]Power of Two
- Leetcode: Power of Two
- [LeetCode]Power of Two
- leetcode | Power of Two
- 【leetcode】Power of Two
- [LeetCode]Power of Two
- [leetcode] Power of two
- LeetCode Power of Two
- Linux-grep命令小记
- 通过apt-get 安装java,JAVA_HOME 的路径
- Hello world!
- NYOJ71 独木舟上的旅行
- Day 5(11.7):(5)练习
- *LeetCode-Power of Two
- PostgreSQL中的数组与Any
- Struts2+Spring+Hibernate整合的例子
- c++在类的内部访问全局变量
- Bootstrap初级用户谈谈网页在手机上的显示效果优化
- C#编写NotifyIcon 将窗口最小化到托盘
- 开启Python
- [Python] Numpy学习笔记(二)
- MyEclipse的基本使用