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 |
Tags
- 금융문자분석경진대회
- hackerrank
- Docker
- programmers
- 파이썬
- 코로나19
- SW Expert Academy
- PYTHON
- 더현대서울 맛집
- 데이콘
- leetcode
- Baekjoon
- 편스토랑
- Real or Not? NLP with Disaster Tweets
- 맥북
- github
- Kaggle
- 프로그래머스 파이썬
- 우분투
- Git
- dacon
- ChatGPT
- AI 경진대회
- ubuntu
- gs25
- 자연어처리
- 편스토랑 우승상품
- 프로그래머스
- 백준
- 캐치카페
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


SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'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 |