Skip to content

Commit f4f090c

Browse files
authored
Merge pull request #1187 from AlgorithmWithGod/LiiNi-coder
[20251021] PGM / LV2 / 다음 큰 숫자 / 이인희
2 parents d9a9b89 + 8c578d1 commit f4f090c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
```java
2+
class Solution {
3+
public int solution(int n) {
4+
int answer = 0;
5+
int i = n+1;
6+
int n1 = get1OfBinary(n);
7+
while(get1OfBinary(i) != n1){
8+
i++;
9+
}
10+
return i;
11+
}
12+
public static int get1OfBinary(int n){
13+
int result = 0;
14+
while(n>1){
15+
result += n%2;
16+
n/=2;
17+
}
18+
if(n==1){
19+
result++;
20+
}
21+
return result;
22+
}
23+
}
24+
```

0 commit comments

Comments
 (0)