728x90
반응형
문제
반응형
풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class Solution {
public int solution(int n) {
int answer = 0;
String three = Integer.toString(n, 3); //n을 3진법으로 변환
StringBuffer sb = new StringBuffer(three); //reverse를 쓰기위해 stringbuffer사용
String rev = sb.reverse().toString();
answer = Integer.parseInt(rev, 3); //three를 10진법으로 변환
return answer;
}
}
|
cs |
728x90
반응형
'[JAVA] 프로그래머스 스쿨 > JAVA Lv.1' 카테고리의 다른 글
[프로그래머스/Java] Lv.1 신규 아이디 추천 (0) | 2023.01.22 |
---|---|
[프로그래머스/Java] Lv.1 내적 (0) | 2023.01.22 |
[프로그래머스/Java] Lv.1 두 개 뽑아서 더하기 (0) | 2023.01.22 |
[프로그래머스/Java] Lv.1 [카카오 인턴] 키패드 누르기 (0) | 2023.01.22 |
[프로그래머스/Java] Lv.1 실패율 (0) | 2023.01.22 |