Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Binary Tree
- Matrix
- array
- simulation
- 구현
- 코딩테스트
- implement
- Counting
- greedy
- hash table
- Method
- 코테
- Tree
- SQL
- database
- two pointers
- Binary Search
- sorting
- Number Theory
- dynamic programming
- geometry
- Data Structure
- Stack
- 파이썬
- java
- 자바
- bit manipulation
- Class
- string
- Math
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 342. Power of Four 본문
1. Input
1) 정수 n
2. Output
1) n이 4의 거듭제곱이면 true, 아니면 false 반환
3. Constraint
1) - 2^31 <= n <= 2^31 - 1
4. Example
Input: n=16 -> Output: true
Input: n=17 -> Output: false
5. Code
1) 첫 코드(2022/07/19)
if(n==1) return true;
if(n<=0) return false;
double num = n;
while(num>=4)
num /= 4;
if(num==1) return true;
else return false;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 412. Fizz Buzz (0) | 2022.11.29 |
---|---|
[LeetCode/Easy] 344. Reverse String (0) | 2022.11.29 |
[LeetCode/Easy] 338. Counting Bits (0) | 2022.11.29 |
[LeetCode/Easy] 326. Power of Three (0) | 2022.11.29 |
[프로그래머스/Lv.2] 영어 끝말잇기 (0) | 2022.11.29 |