231. Power of Two
来源:互联网 发布:手机视频播放器 知乎 编辑:程序博客网 时间:2024/06/05 22:43
Given an integer, write a function to determine if it is a power of two.
Credits:
Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.
Subscribe to see which companies asked this question
注意 处理负数的情况。
class Solution {public: bool isPowerOfTwo(int n) { // if(n<=0) return 0; return (n>0) && (n&(n-1))==0; }};
0 0
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- APICloud的config.xml应用配置的说明
- 07.03-C
- APICloud模块的引入、服务器数据对接,APP数据存储方式
- java开发各层对象含义
- 2-6 ance desc选择器
- 231. Power of Two
- 卷积神经网络及其在图像处理中的应用
- MySQL 5.6 for Windows 解压缩版配置安装
- 2017 Indeed-tokyo笔试题-6*6的矩阵放置元素
- java多线程基础总结
- 前端性能优化:jquery性能优化
- 2-7parent > child选择器
- Tomcat7源码分析——启动过程和类加载器
- 插入排序