From 6759880d1216b2361ca8a90d19c395bca2f6b79f Mon Sep 17 00:00:00 2001 From: dmswl6310 Date: Thu, 3 Sep 2026 00:02:52 +0900 Subject: [PATCH] 0902 --- .../3827. Count Monobit Integers.js" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "leetcode3/\355\231\251\354\235\200\354\247\200/3827. Count Monobit Integers.js" 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