diff --git "a/leetcode3/\355\231\251\354\235\200\354\247\200/3827. Count Monobit Integers.js" "b/leetcode3/\355\231\251\354\235\200\354\247\200/3827. Count Monobit Integers.js" new file mode 100644 index 00000000..4832364d --- /dev/null +++ "b/leetcode3/\355\231\251\354\235\200\354\247\200/3827. Count Monobit Integers.js" @@ -0,0 +1,13 @@ +/** + * @param {number} n + * @return {number} + */ +var countMonobit = function(n) { + // 0은 꼭 포함, 나머지는 전부 1로만 이루어짐 + let count=1; + const binary=n.toString(2); + count+=(binary.length-1); + if(!binary.includes("0")) count+=1; + + return count; +}; \ No newline at end of file