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