Skip to content

Commit 5936c43

Browse files
committed
[level 2] Title: 다음 큰 숫자, Time: 0.02 ms, Memory: 54 MB -BaekjoonHub
1 parent ccea6fb commit 5936c43

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

프로그래머스/2/12911. 다음 큰 숫자/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# [level 2] 다음 큰 숫자 - 12911
22

3-
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12911)
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/12911#qna)
44

55
### 성능 요약
66

7-
메모리: 9.89 MB, 시간: 0.00 ms
7+
메모리: 54 MB, 시간: 0.02 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2024년 2월 1일 21:35:49
19+
2025년 05월 31일 22:46:21
2020

2121
### 문제 설명
2222

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int solution(int n) {
3+
int answer = 0;
4+
int start = Integer.bitCount(n); //bitCount는 이진수에서 1의 갯수를 반환해주는 함수이다
5+
6+
while(true){
7+
int next = Integer.bitCount(++n);
8+
if(start == next){ //1의 갯수가 같다면 루프 종료
9+
answer = n;
10+
break;
11+
}
12+
}
13+
return answer;
14+
}
15+
}

0 commit comments

Comments
 (0)