Power of Two
来源:互联网 发布:付费网络推广 编辑:程序博客网 时间:2024/06/07 17:55
Given an integer, write a function to determine if it is a power of two.
方法: 排除负数与0的情况。
class Solution {public: bool isPowerOfTwo(int n) { return (n>0&&(n&(n-1))==0)?true:false; }};
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
- 设计模式学习笔记——建造者(Builder)模式
- NodeJS之------(Url,QueryString,Path)模块
- java源码解读之HashSet------jdk 1.7
- css权限问题
- 谈谈Java内存管理
- Power of Two
- 内部类
- TCP/UDP相关知识总汇
- Lecture 14 Competive Analysis
- Java中String与BufferedReader、InputStream转换
- Linux操作系统文件系统基础知识详解
- shell awk 多列求和
- 小短腿的减肥路
- Perl 交互命令行参数