LeetCode No.231 Power of Two
来源:互联网 发布:网络机顶盒直播软件下载 编辑:程序博客网 时间:2024/06/06 03:49
Given an integer, write a function to determine if it is a power of two.
===================================================================
题目链接:https://leetcode.com/problems/power-of-two/
题目大意:判断一个数是否为2的幂。
思路:位操作。
参考代码:
class Solution {public: bool isPowerOfTwo(int n) { if ( n == 0 ) return false ; while ( n ) { if ( n & 1 && ( n >> 1 ) != 0 ) return false ; n >>= 1 ; } return true ; }};
0 0
- Leetcode NO.231 Power of Two
- LeetCode--No.231--Power Of Two
- LeetCode No.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
- 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
- Atitit 数据处理查询 中的异常标准化草案 jpa jdbc hb oql规范attilax总结
- uva11549 Calculator Conundrum【解法一】
- 闭包
- 如何使用Valgrind memcheck工具进行C/C++的内存泄漏检测
- svn add ignore
- LeetCode No.231 Power of Two
- hibernate中sql关联两个表,不用别名会出错
- 安卓入门之界面编程----View与ViewGroup的概念
- 构造函数
- Android开发中,那些让你相见恨晚的方法、类或接口
- JPA常用注解
- asp.net——Html.ActionLink的用法
- http状态码
- Android源码之状态栏和锁屏