LeetCode : Power of Three
来源:互联网 发布:芈月传 大秦帝国 知乎 编辑:程序博客网 时间:2024/04/26 04:24
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.
Subscribe to see which companies asked this question.
class Solution {public: bool isPowerOfThree(int n) { if(n<=0) return false; if(n==1) return 1; else if(n%3==0) return isPowerOfThree(n/3); else return false; }};
0 0
- leetcode Power of Three
- Leetcode: Power of Three
- LeetCode Power of Three
- [leetcode]Power of Three
- LeetCode-Power of Three
- leetcode power of three
- LeetCode----Power of Three
- LEETCODE--Power of Three
- 【leetcode】Power of Three
- leetcode---Power of Three
- 《leetCode》:Power of Three
- leetcode: Power of Three
- [LeetCode]Power of Three
- leetcode Power of Three
- LeetCode|Power of three
- LeetCode - Power of Three
- Leetcode - Power of Three
- LeetCode:Power of Three
- POI操作word模板并生成新的word.docx
- 【译】关键渲染路径
- 常用 Git 命令清单
- 基本的引导:用MVP构建你的Android应用架构part1
- ionic2页面回传值,关于Typescript的Promise承诺
- LeetCode : Power of Three
- 推荐系统概述
- 用辗转相除法求最大公约数
- 秒杀系统架构
- AVR单片机笔记 mega16 PC口2345管脚
- MQTT---HiveMQ源码详解(十六)TopicTree
- CPU简史
- 记面试中知识疑惑点
- c语言进程池的简单实现