[Leetcode]Power of Four
来源:互联网 发布:java源码是什么 编辑:程序博客网 时间:2024/05/17 08:50
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.
Example:
Given num = 16, return true.Given num = 5, return false.
Follow up: Could you solve it without loops/recursion?
Credits:
Special thanks to @yukuairoy for adding this problem and creating all test cases.
Subscribe to see which companies asked this question
class Solution {public: /*algorithm check trailing 0 bit count must even number */ bool isPowerOfFour(int num) { if(num < 1)return false; while(num%4==0){ num /= 4; } return num == 1; }};
0 0
- [LeetCode]Power of Four
- Power of Four-Leetcode
- LeetCode Power of Four
- LeetCode - Power of Four
- LeetCode:Power of Four
- leetcode---Power of Four
- [LeetCode] Power of Four
- 【Leetcode】Power of Four
- [Leetcode]Power of Four
- LeetCode: Power of Four
- LeetCode Power of Four
- [Leetcode] Power of Four
- LEETCODE-- Power of Four
- leetcode[Power of Four]
- leetcode笔记:Power of Four
- LeetCode *** 342. Power of Four
- (LeetCode 342) Power of Four
- LeetCode(65)-Power of Four
- 使用Class签名的防破解技术介绍
- codeforces #359 前三题题解
- git https方式pull、push时,提示:error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh
- 目的性越强 你的网站数据分析越有价值!
- getCacheDir()、getFilesDir()、getExternalFilesDir()、getExternalCacheDir() 解析
- [Leetcode]Power of Four
- libevent的使用方法--回显服务器的简单实例
- android studio导出apk步骤
- C#操作SQLite数据库
- LevelDB : Arena
- 按照文本格式生成sql语句--查找并替换语句
- 数组中的逆序对(剑指offer)
- python爬取bilibili番剧图片
- python多线程学习