Integer.bitCount
정수를 매개변수로 넣었을때 그 정수의 1의 개수를 반환한다.
https://school.programmers.co.kr/learn/courses/30/lessons/12911
class Solution {
public int solution(int n) {
int answer = n+1;
int nBit = Integer.bitCount(n);
while (true) {
int ansBit = Integer.bitCount(answer);
if (ansBit == nBit) {
return answer;
} else {
answer++;
}
}
}
}
https://blog.yevgnenll.me/posts/java-integer-bit-count-function