Leetcode 231. Power of Two (Easy) (cpp)
2016-07-13 18:16
597 查看
Leetcode 231. Power of Two (Easy) (cpp)
Tag: Math, Bit Manipulation
Difficulty: Easy
Tag: Math, Bit Manipulation
Difficulty: Easy
/* 231. Power of Two (Easy) Given an integer, write a function to determine if it is a power of two. */ class Solution { public: bool isPowerOfTwo(int n) { return n > 0 && ((n & (n - 1)) == 0 ); } };
相关文章推荐
- 浅谈C语言中"#ifndef/#define/#endif"的作用
- (C++)UNION结构
- 常用算法题目3道
- 浅析长度为0的数组
- OpenSSLRSA.cpp
- 指针小解
- leetcode算法总结之字符串除空格操作
- C语言
- C++模板类注意事项
- c/c++ 友元函数友元类,及const作用
- C++ RegCreateKeyEx成功了,但是注册表并没有这一项
- C语言常用基础数据类型和变量
- [leetcode]climbing-stairs 动态规划 C++
- c++三目运算符的坑
- C++中单字符与字符串的读取
- 371. Sum of Two Integers
- Leetcode 9. Palindrome Number (Easy) (cpp)
- C++11:lambda表达式、bind函数、function类型
- C++内存模型与名称空间(存储持续性、作用域、链接性、动态内存分配、命名空间)
- Win7 VC++6.0打开文件崩溃 FileTool.dll