231. Power of Two
来源:互联网 发布:mac 任务管理工具 编辑:程序博客网 时间:2024/06/05 03:40
Given an integer, write a function to determine if it is a power of two.
class Solution {public: bool isPowerOfTwo(int n) { int s = 0; if(n < 1) return false; for(int i = 0; i < 32; ++i){ if(n & 1) ++s; n >>= 1; } if(s == 1) return true; return false; }};
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
- Android自定义AppCompat主题取消标题栏和状态栏方法
- CSS_选择器
- 9.2.2
- 解密Java内存溢出之持久代
- Java笔记 - IO流(FileReader,FileWriter)
- 231. Power of Two
- 深挖SpringMVC_07_ 细说org.springframework.context.ApplicationContextAware
- 1013. 数素数 (20)
- Linux 文件符操作
- 找出两个链表的交叉点
- keychain
- LeetCode 257. Binary Tree Paths
- 小学生算术
- [BZOJ4551][Tjoi2016&Heoi2016]树 dfs序+线段树