Skip to content

Commit 4e67e1d

Browse files
Merge pull request #1801 from CodingTestStudy2/황은지
[황은지] Day12
2 parents 25ce1f0 + 8e547a5 commit 4e67e1d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {number} num
3+
* @return {number}
4+
*/
5+
var findComplement = function (num) {
6+
const binary = num.toString(2);
7+
return parseInt(
8+
binary
9+
.split("")
10+
.map((digit) => (digit === "1" ? "0" : "1"))
11+
.join(""),
12+
2,
13+
);
14+
};

0 commit comments

Comments
 (0)