(LeetCode)Power of Four --- 4的次方,python实现
来源:互联网 发布:linux重命名mv命令 编辑:程序博客网 时间:2024/06/05 13:08
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
解题分析:
对于这种的题目,类似于求解3, 2的次方一样。可以无限循环除以4然后判断最后能否除尽。
class Solution(object): def isPowerOfFour(self, num): while num and (num%4==0): num /= 4 return num == 1
0 0
- (LeetCode)Power of Four --- 4的次方,python实现
- Power of Four and Power of Three - 4的次方和3的次方
- [leetcode: Python]342. Power of Four
- [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 342. Power of Four 4的幂指数
- 多语言版本网站 数据库设计 What are best practices for multi-language database design?
- Android面试题整理
- 斯坦福cs224d(深度学习在自然语言处理上的应用)Lecture 2 note2
- AFURLSessionManager 上传下载使用
- SLF4J+Logback 日志框架使用
- (LeetCode)Power of Four --- 4的次方,python实现
- Codeforces 161 D Distance in Tree 树形DP
- 实现add(2, 5); // 7 add(2)(5); // 7
- Android安卓开发知识库汇总
- Android应用内存泄露分析、改善经验总结
- VC++调用libcurl的VC库使用详解
- Spring Boot
- Android 内存泄漏总结
- UVa 1595(Symmetry)