231. Power of Two
来源:互联网 发布:python 字典嵌套 list 编辑:程序博客网 时间:2024/05/16 09:37
题目
Given an integer, write a function to determine if it is a power of two.
分析
循环除2。
class Solution {public: bool isPowerOfTwo(int n) { if(n<=0) return false; if(n==1) return true; while(n!=2) { if(n%2==1) return false; n=n/2; } return true; }};
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
- linux查看系统设备信息
- Linux文件访问
- 内存泄漏检测工具—LeakCanary的配置和使用
- Java NIO系列教程(五) 通道之间的数据传输
- Hibernate的检索方式(3)sql
- 231. Power of Two
- SpringMvc 使用poi导入导出Excel
- 计蒜客 人人都有极客精神(模拟)
- C++ new delete
- 深度学习(DL)与卷积神经网络(CNN)学习笔记随笔-01-CNN基础知识点
- 【Maven】-安装和配置
- Swift 性能探索和优化分析
- android graphic(19)—why Android's UI was designed the way it is and how it actually works
- OTL 简介