Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- Kaggle
- PYTHON
- 파이썬
- Docker
- 금융문자분석경진대회
- Baekjoon
- 우분투
- github
- 백준
- SW Expert Academy
- 프로그래머스 파이썬
- 데이콘
- 편스토랑 우승상품
- 코로나19
- 맥북
- Git
- AI 경진대회
- 캐치카페
- 편스토랑
- leetcode
- ChatGPT
- 프로그래머스
- hackerrank
- ubuntu
- programmers
- gs25
- Real or Not? NLP with Disaster Tweets
- 자연어처리
- dacon
- 더현대서울 맛집
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 342. Power of Four (Python) 본문
728x90
반응형
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.
Example 1:
Input: 16
Output: true
Example 2:
Input: 5
Output: false
Follow up: Could you solve it without loops/recursion?
Accepted
Solution
class Solution:
def isPowerOfFour(self, num: int) -> bool:
if num <= 0:
answer =False
else:
while num % 4 == 0:
num = num / 4
if num == 1:
answer = True
else:
answer = False
return answer
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 1360. Number of Days Between Two Dates (Python) (0) | 2020.07.26 |
---|---|
[leetCode] 1154. Day of the Year (Python) (0) | 2020.07.25 |
[leetCode] 692. Top K Frequent Words (Python) (0) | 2020.07.23 |
[leetCode] 386. Lexicographical Numbers (Python) (0) | 2020.07.22 |
[leetCode] 172. Factorial Trailing Zeroes (Python) (0) | 2020.07.21 |
Comments