uploaded at 2022. 12. 25. 오전 2:35:57

This commit is contained in:
rl544
2022-12-25 02:35:58 +09:00
parent 0c45fe78d8
commit b958d48a60
@@ -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;
}
}