Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08dda97

Browse filesBrowse files
authored
Merge pull request AlgoStudyGroup#142 from qilingit/day28
Add Java solution for day28: Counting Bits
2 parents 17328a3 + 80fd3c6 commit 08dda97
Copy full SHA for 08dda97

File tree

Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int[] countBits(int num) {
3+
int[] res = new int[num+1];
4+
for (int i = 1; i <= num; i++) {
5+
res[i] = res[i >> 1] + i % 2;
6+
}
7+
8+
return res;
9+
}
10+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.