programmers_다음 큰 숫자_java
2023. 4. 3. 12:23ㆍAlgorithm/Programmers
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/12911
class Solution {
public int solution(int n) {
int answer = n+1;
int cntOne = Integer.bitCount(n);
while(true){
if(Integer.bitCount(answer) == cntOne){
break;
}
answer++;
}
return answer;
}
}
'Algorithm > Programmers' 카테고리의 다른 글
programmers_예상 대진표_java (1) | 2023.04.03 |
---|---|
programmers_짝지어 제거하기_java (0) | 2023.04.03 |
programmers_피보나치 수_java (0) | 2023.04.03 |
programmers_구명보트_java (0) | 2023.04.03 |
programmers_이진 변환 반복하기_java (0) | 2023.04.01 |