We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dabcb5f commit 5d5ebd4Copy full SHA for 5d5ebd4
1 file changed
number-of-1-bits/essaysir.java
@@ -0,0 +1,11 @@
1
+class Solution {
2
+ public int hammingWeight(int n) {
3
+ // 이진수로 바꾸고, 1 이 몇개 있는 지 파악한다.
4
+ return Integer.bitCount(n);
5
+
6
+ // 추가 풀이.
7
+ // String ans = Integer.toBinaryString(n).replace("0","");
8
+ // return ans.length();
9
+ }
10
+}
11
0 commit comments