leetcode326
public class Solution {
public bool IsPowerOfThree(int n) {
return n > && ( % n == );
}
}
https://leetcode.com/problems/power-of-three/#/description
使用循环实现,python
class Solution:
def isPowerOfThree(self, n: int) -> bool:
while n > and n % == :
n = n //
return n ==
leetcode326的更多相关文章
- LeetCode----326. Power of Three(Java)
package isPowerOfThree326; /* Given an integer, write a function to determine if it is a power of th ...
- 每天一道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 it ...
- [python语法巩固][leetcode326][Power of Three]
题目大意: 让你判断一个int是否为3的幂; 最简单的思路 C++ class Solution { public: bool isPowerOfThree(int n) { for(long lon ...
- [Swift]LeetCode326. 3的幂 | Power of Three
Given an integer, write a function to determine if it is a power of three. Example 1: Input: 27 Outp ...
- leetcode231 2的幂 leetcode342 4的幂 leetcode326 3的幂
1.2的幂 正确写法: class Solution { public: bool isPowerOfTwo(int n) { ) return false; )) == ; } }; 错误写法1: ...
- LeetCode 326
Power of Three Given an integer, write a function to determine if it is a power of three. Follow up: ...
随机推荐
- SQLyog Enterprise常用快捷键
1. SQL格式化 F12 格式化当前行所在的SQL Ctrl+F12 格式化选中的SQL Shift+F12 格式化所有SQL 2. 窗口操作 Ctrl+T 打开一个新的查询窗口 Alt+ ...
- LeetCode-Microsoft-Add Two Numbers II
You are given two non-empty linked lists representing two non-negative integers. The most significan ...
- Vue2.x directive自定义指令
directive自定义指令 除了默认设置的核心指令( v-model 和 v-show ),Vue 也允许注册自定义指令. 注意,在 Vue2.0 里面,代码复用的主要形式和抽象是组件——然而,有的 ...
- L5负载均衡
L5负载均衡组件的功能职责 L5的功能特征如下: 名字服务:以SID(由模块ID和命令字ID组成)为关键字,通过SID取得真正的IP和端口地址,使得IP和端口配置对调用者透明,运维变更配置更方便: 负 ...
- 【转】Linux的五个查找命令:find,locate,whereis,which,type
原文网址:http://www.ruanyifeng.com/blog/2009/10/5_ways_to_search_for_files_using_the_terminal.html 最近,我在 ...
- 【转】每天一个linux命令(5):rm 命令
原文网址:http://www.cnblogs.com/peida/archive/2012/10/26/2740521.html 昨天学习了创建文件和目录的命令mkdir ,今天学习一下linux中 ...
- php中__get()和__set的用法
php版本5.6 一般来说,总是把类的属性定义为private,这更符合现实的逻辑.但是,对属性的读取和赋值操作是非常频繁的,因此在PHP5中,预定义了两个函数“__get()”和“__set()”来 ...
- gitlab配合walle搭建发布系统
理解walle实现发布代码的原理: 宿主机:walle系统搭建的服务器以及拉取gitlab代码的服务器,这个时候gitlab一般都是另外一台服务器. 目标机器:版本最终发布的目的机器,或者目的机群 ...
- android自定义tabhost,tabcontent用intent获得
地址:http://my.oschina.net/aowu/blog/36282 自己改的自定义tabhost组建,效果图如左.有更好的朋友可以相互交流一下,嘿嘿. 1.先上AndroidManife ...
- C/C++基础----顺序容器
通常没有特别的原因,用vector. list和forward_list有额外的内存开销,如果有很多小元素,不要使用. 如果只在读取输入时需要在容器中间位置插入元素,随后需要随机访问. 1确定是否真正 ...