class Solution {
// Integer.bitCount : 비트로 변환했을 때 1의 갯수 반환
public int solution(int n) {
int n_num = Integer.bitCount(n);
// 주어진 숫자의 비트 형식 1의 갯수 세기
int k = n+1;
// n보다 큰 임의의 정수 K
while(true) {
int k_num = Integer.bitCount(k);
// K의 비트 형식 1의 갯수 세기
if(n_num == k_num) {
break;
// n과 k의 비트 형식 1 갯수가 같으면 반환
}
k++;
// 비트 형식 1 갯수가 다르다면 K의 크기 1 추가
}
return k;
}
}
https://shorturl.fm/ypgnt
https://shorturl.fm/JtG9d
https://shorturl.fm/I3T8M
https://shorturl.fm/uyMvT
https://shorturl.fm/YZRz9
Get paid for every referral—sign up for our affiliate program now! https://shorturl.fm/dEWrL
Promote, refer, earn—join our affiliate program now! https://shorturl.fm/D8BjN
Maximize your income with our high-converting offers—join as an affiliate! https://shorturl.fm/Zmgi2
Tap into a new revenue stream—become an affiliate partner! https://shorturl.fm/1BqVC
Start earning passive income—join our affiliate network today! https://shorturl.fm/9L970