Skip to content

Commit 87f5d0e

Browse files
authored
Merge pull request #1127 from AlgorithmWithGod/lkhyun
[20251015] PGM / Lv2 / 점프와 순간 이동 / 이강현
2 parents 01578b5 + c0675dc commit 87f5d0e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
```java
2+
import java.util.*;
3+
4+
public class Solution {
5+
public int solution(int n) {
6+
int ans = 0;
7+
8+
while(n>0){
9+
if(n%2==0){
10+
n /= 2;
11+
}else{
12+
ans++;
13+
n--;
14+
}
15+
}
16+
17+
return ans;
18+
}
19+
}
20+
```

0 commit comments

Comments
 (0)