💻 문제 출처 : 프로그래머스_다음 큰 숫자
class Solution {
public int solution(int n) {
int oneCounter = Integer.toBinaryString(n).replace("0", "").length();
int findNum = n + 1;
while(true) {
int check = Integer.toBinaryString(findNum).replace("0", "").length();
if(check == oneCounter) return findNum;
findNum++;
}
}
}
class Solution {
public int solution(int n) {
int a = Integer.bitCount(n);
int compare = n+1;
while(true) {
if(Integer.bitCount(compare)==a)
break;
compare++;
}
return compare;
}
}