https://programmers.co.kr/learn/courses/30/lessons/12911
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class Solution {
public int solution(int n) {
int paramBitCount = Integer.bitCount(n);
int answer = 0;
for (int i = n + 1; i < 1_000_000; i++) {
if (Integer.bitCount(i) == paramBitCount) {
return i;
}
}
return 0;
}
}
|
cs |