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