uploaded at 2022. 12. 25. 오전 2:35:57
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/12980
|
||||||
|
|
||||||
|
public class Solution {
|
||||||
|
public int solution(int n) {
|
||||||
|
int ans = 0;
|
||||||
|
String ns = Integer.toBinaryString(n);
|
||||||
|
for(char a : ns.toCharArray()){
|
||||||
|
ans += Character.getNumericValue(a);
|
||||||
|
}
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user