Skip to content

Commit cc421d2

Browse files
authored
Merge pull request #1093 from limlimjo/main
[jj7779607] Week14
2 parents bc22845 + 4e39c51 commit cc421d2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

counting-bits/limlimjo.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// 시간복잡도: O(n log n)
2+
// 공간복잡도: O(n)
3+
4+
/**
5+
* @param {number} n
6+
* @return {number[]}
7+
*/
8+
var countBits = function(n) {
9+
let result = [];
10+
for (let i=0; i<=n; i++) {
11+
result.push(i.toString(2).replace(/0/g, '').length);
12+
}
13+
14+
return result;
15+
};

0 commit comments

Comments
 (0)