Leetcode 326:Power of Three
来源:互联网 发布:sql count1什么意思 编辑:程序博客网 时间:2024/05/22 06:27
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
//给定一个整数,编写函数判断它是否为3的幂class Solution {public: bool isPowerOfThree(int n) { if(n>1) { while(n%3==0) n=n/3; } return n==1; }};
0 0
- leetcode-326-Power of Three
- [LeetCode 326] Power of Three
- LeetCode 326:Power of Three
- Leetcode 326:Power of Three
- leetcode-326-Power of Three
- LeetCode 326 Power of Three
- [LeetCode 326] Power of Three
- (LeetCode 326)Power of Three
- LeetCode-326 Power of Three
- LeetCode-326: Power of Three
- LeetCode 326 Power of Three
- Leetcode 326 : Power of Three
- Leetcode 326 Power of Three
- leetcode-326-Power of Three
- Leetcode 326 Power of Three
- leetcode Power of Three
- Leetcode: Power of Three
- LeetCode Power of Three
- 千万要小心STL的iterator失效[难度:初级]
- 类加载器
- Collection
- centos 关机和重启命令详解
- [leetcode] Burst Balloons
- Leetcode 326:Power of Three
- Xcode7 使用WebView loadRequest发送HTTP请求的问题
- zstu 2554 过河卒
- Hbase hirachical structure
- Linux socket 本地进程间通信
- 观察者模式
- mysql创建触发器错误提示:Can not update in stored function/trigger already used by statement invoked
- Java9积极解决Linux中的GTK GUI难题
- VS2012发布网站详细步骤,同样适合vs2013,亲身试过