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;
}
}
Get started instantly—earn on every referral you make! https://shorturl.fm/grpcn
Refer and earn up to 50% commission—join now! https://shorturl.fm/vQ3Tp
Refer customers, collect commissions—join our affiliate program! https://shorturl.fm/twGgO
Join our affiliate community and start earning instantly! https://shorturl.fm/LBHpy
Unlock top-tier commissions—become our affiliate partner now! https://shorturl.fm/J8A6M
Tap into unlimited earnings—sign up for our affiliate program! https://shorturl.fm/1Yvdd
Monetize your traffic instantly—enroll in our affiliate network! https://shorturl.fm/gYA4O
Get paid for every click—join our affiliate network now! https://shorturl.fm/711Wn
Share our products, earn up to 40% per sale—apply today! https://shorturl.fm/9tbQ8
Share our products and watch your earnings grow—join our affiliate program! https://shorturl.fm/yZvkE