leetcode342
public class Solution {
public bool IsPowerOfFour(int num) {
return (num > ) && ((num & (num - )) == ) && ((num & 0x55555555) == num);
}
}
https://leetcode.com/problems/power-of-four/#/description
leetcode342的更多相关文章
- 每天一道LeetCode--342. Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Giv ...
- leetcode342——Power of Four(C++)
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Giv ...
- leetcode342合理运用位操作判断4的幂
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Gi ...
- [Swift]LeetCode342. 4的幂 | Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example 1: ...
- LeetCode-342:Power of Four
This is another "Pick One" Problem :[Problem:342-Power of Four] Given an integer (signed ...
- leetcode231 2的幂 leetcode342 4的幂 leetcode326 3的幂
1.2的幂 正确写法: class Solution { public: bool isPowerOfTwo(int n) { ) return false; )) == ; } }; 错误写法1: ...
- LeetCode191 Number of 1 Bits. LeetCode231 Power of Two. LeetCode342 Power of Four
位运算相关 三道题 231. Power of Two Given an integer, write a function to determine if it is a power of two. ...
- LeetCode 342
Power of Four Given an integer (signed 32 bits), write a function to check whether it is a power of ...
随机推荐
- day35 python学习GIL解释器锁
二 GIL介绍 GIL本质就是一把互斥锁,既然是互斥锁,所有互斥锁的本质都一样,都是将并发运行变成串行,以此来控制同一时间内共享数据只能被一个任务所修改,进而保证数据安全. 可以肯定的一点是:保护不同 ...
- openresty 使用cuid 类库生成短链接id
cuid 是一个不错的id 生成算发,类似的有shortid .hashid 演示使用lua 包集成openresty 做测试 使用docker-compose 运行 dockerfile FROM ...
- Oracle sql之条件语句 循环语句
一 IF..THENIF condition THEN statements 1; statements 2; ....END IF; 二 IF..THEN...ELSEIF condit ...
- Linux内核链表
内核链表的设计思路内核链表中自己实现了一个纯链表(纯链表就是没有数据区域,只有前后向指针)的封装,以及纯链表的各种操作函数(节点创建.插入.删除.遍历······).这个纯链表本身自己没有任何用处,它 ...
- 【转】每天一个linux命令(59):rcp命令
原文网址:http://www.cnblogs.com/peida/archive/2013/03/14/2958685.html rcp代表“remote file copy”(远程文件拷贝).该命 ...
- zsh 使用
使用ctrl+r,弹出搜索框: bck-i-search: mac os 系统默认的终端为bash,切换该终端为zsh,可以用以下命令: chsh -s /bin/zsh 如过要切回默认终端bash, ...
- scala的hello world出现的问题
build出现: Error:scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerExceptionError compil ...
- Jsp Cookie
cookie它是用户访问Web服务器时,服务器在用户硬盘上存放的信息. 1.使用Servlet实现cookie @WebServlet("/CookieServlet") publ ...
- 如何使用Django 启动命令行及执行脚本
使用django启动命令行和脚本,可以方便的使用django框架做开发,例如,数据库的操作等. 下面分别介绍使用方法. django shell的启动 启动命令: $/data/python-virt ...
- svn 提交代码 自动过滤技巧,自动过滤不想提交的文件和文件夹
原文:http://www.cnblogs.com/codealone/p/3208620.html 打开SVN客户端-----常规设置------全局忽略样式,添加 bin obj debug Re ...