Power of Two
来源:互联网 发布:pano2vr player.js 编辑:程序博客网 时间:2024/06/10 01:12
Given an integer, write a function to determine if it is a power of two.
class Solution(object): def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ # return n == 2**(len(bin(n)) - 3) if n == 1: return True bin_n = bin(n) if bin_n[2] == '1' and bin_n[3:] == '0' * (len(bin_n) - 3): return True return False
class Solution(object): def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ return n > 0 and n & (n - 1) == 0
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
- 哈弗曼树
- C语言中%d,%s,%x,%f,%.100f,%的意思
- Elasticsearch增、删、改、查操作深入详解
- AS导入Library的时候出现问题,依赖库不显示
- NLTK下载
- Power of Two
- eclipse新建几种项目区别
- CSDN博客地址
- AVL平衡树
- APMserv 5.2.6的简单使用
- Get Docker for CentOS
- Multicore Programming SIMD
- g-sensor bmc156数据传输流程(compass部分)
- Java重写toString方法