From 0ea6ce851d08abd7f1c5175eb7fc5ba4a8224720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81?= Date: Tue, 17 Mar 2026 10:19:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?isPalindrome=20=ED=92=80=EC=9D=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- valid-palindrome/junzero741.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 valid-palindrome/junzero741.ts diff --git a/valid-palindrome/junzero741.ts b/valid-palindrome/junzero741.ts new file mode 100644 index 000000000..1f5bf7cbd --- /dev/null +++ b/valid-palindrome/junzero741.ts @@ -0,0 +1,29 @@ +// TC: O(n) +// SC: O(1) +function isPalindrome(s: string): boolean { + + let L = 0; + let R = s.length-1; + + while(R > 0 && L < s.length - 1 && L <= R) { + if(!isAlphanumeric(s[L])) { + L++; + continue; + } + if(!isAlphanumeric(s[R])) { + R--; + continue; + } + if(s[L].toLowerCase() !== s[R].toLowerCase()) { + return false; + } + L++; + R--; + } + + return true; +}; + +function isAlphanumeric(str: string): boolean { + return /^[a-zA-Z0-9]+$/.test(str); +} From 955cce81aa6b2b333c5241203a9b2ee951f9d28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=98=81?= Date: Wed, 18 Mar 2026 09:15:36 +0900 Subject: [PATCH 2/2] =?UTF-8?q?number-of-1-bits=20=ED=92=80=EC=9D=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- number-of-1-bits/junzero741.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 number-of-1-bits/junzero741.ts diff --git a/number-of-1-bits/junzero741.ts b/number-of-1-bits/junzero741.ts new file mode 100644 index 000000000..2c8aa49cd --- /dev/null +++ b/number-of-1-bits/junzero741.ts @@ -0,0 +1,13 @@ +// TC: O(log n) +// SC: O(1) +function hammingWeight(n: number): number { + const binary = n.toString(2); + let bits = 0; + for(let i = 0; i < binary.length; i++) { + if(binary[i] === '1') { + bits++; + } + } + + return bits; +};