231115 다음 큰 숫자

Jongleee·2023년 11월 15일
0

TIL

목록 보기
417/576
public int solution(int n) {
	int targetBitCount = Integer.bitCount(n);

	for (int i = n + 1; i <= 1000000; i++) {
		if (Integer.bitCount(i) == targetBitCount) {
			return i;
		}
	}

	return targetBitCount;
}

출처:https://school.programmers.co.kr/learn/courses/30/lessons/12911

0개의 댓글