LeetCode:326. Power of Three
2019独角兽企业重金招聘Python工程师标准>>>
Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
Credits:
Special thanks to @dietpepsi for adding this problem and creating all test cases.
解答:
func isPowerOfThree(n int) bool {
if n == 0 {
return false
}
c := math.Log10(float64(n)) / math.Log10(3)
d := float64(int64(c))
return (c - d) < 0.0000000001
}
转载于:https://my.oschina.net/ifraincoat/blog/1069049
LeetCode:326. Power of Three相关推荐
- LeetCode 326. Power of Three
题目: Given an integer, write a function to determine if it is a power of three. Follow up: Could you ...
- [leetcode]326. Power of Three(c语言)
题目 Given an integer, write a function to determine if it is a power of three. Follow up: Could you d ...
- LeetCode 326. Power of Three (算法,换底公式)
Given an integer, write a function to determine if it is a power of three. Follow up: Could you do i ...
- leetcode 326. 3的幂(Power of Three)
目录 题目描述: 示例 1: 示例 2: 示例 3: 示例 4: 进阶: 解法: 题目描述: 给定一个整数,写一个函数来判断它是否是 3 的幂次方. 示例 1: 输入: 27输出: true 示例 2 ...
- [LeetCode][JavaScript]Power of Three
Power of Three Given an integer, write a function to determine if it is a power of three. Follow up: ...
- [leetcode] 342. Power of Four
题目 Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example: ...
- leetcode 342. Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Gi ...
- leetcode 231. Power of Two
Given an integer, write a function to determine if it is a power of two. class Solution(object):def ...
- LeetCode - 231. Power of Two
Given an integer, write a function to determine if it is a power of two. Example 1: Input: 16 Output ...
最新文章
- 900 多道 LeetCode 题解,这个 GitHub 项目值得 Star!
- iOS多线程编程之多线程简单介绍(转载)
- JavaScript进阶系列01,函数的声明,函数参数,函数闭包
- Cordova for iOS[ PhoneGap]
- Redis根据是否存在设置值
- linux中sh+$0,浅谈linux中shell变量$#,$@,$0,$1,$2的含义解释
- 可视化日历(Java实现)
- bzoj 2296: 【POJ Challenge】随机种子
- opencv 二值化_Python-OpenCV获取图像轮廓的图像处理方法
- 学术不端!211大学一名博士被撤销学位!
- 【C#夯实】我与接口二三事:IEnumerable、IQueryable 与 LINQ
- 广州爱立信java笔试题_爱立信笔试经历
- 基于sklearn分析特征工程(特征预处理、特征选择、降维)
- iOS开发之画图板(贝塞尔曲线)
- HTML_BOM-01
- 人工智能成功与冠状病毒抗争,但个人隐私令人担忧
- 自动识别并汇总发票信息的智能机器人来啦!
- android中bmob云存储,Android中的Bmob移动后端云服务器功能
- 虚拟机怎么安装软件 Mac虚拟机怎么安装软件
- K8S学习之storageclass