Power of Two
来源:互联网 发布:数据挖掘与数据分析 编辑:程序博客网 时间:2024/06/05 04:33
题目:
Given an integer, write a function to determine if it is a power of two.
解题思路:
class Solution:
# @param {integer} n
# @return {boolean}
def isPowerOfTwo(self, n):
if n<=0:
return False
while n>=2:
if n%2!=0:
return False
n = n/2
return True
0 0
- Power of Two
- [LeetCode] Power of Two
- 【LeetCode】Power of Two
- Power of Two
- power of two
- [Leetcode]Power of Two
- Power of Two
- [leetCode] Power of Two
- Power of Two
- 231Power of Two
- leetcode --Power of Two
- Power of Two
- leetcode: Power of Two
- Power of Two
- Power of Two
- Power of Two
- Leetcode46: Power of Two
- LeetCode Power of Two
- 前端开发常见的面试问题
- 我们是这样理解语言的
- 构造函数、复制构造函数、类型转换构造函数、析构函数
- CASE WHEN THEN的使用方法
- 内存管理
- Power of Two
- nyoj 55 懒省事的小明【贪心+优先队列】
- createjs初学-所有的显示对象介绍(1)
- OC基础12:数字、字符串和集合1
- Android的ActivityGroup与Fragment
- openCV 形态学处理
- 【kmp】POJ-3461 Oulipo
- PostgreSQL分区表的性能损耗验证
- 360面试题--时钟问题