diff --git a/number-of-1-bits/hozzijeong.js b/number-of-1-bits/hozzijeong.js new file mode 100644 index 0000000000..260b1656ea --- /dev/null +++ b/number-of-1-bits/hozzijeong.js @@ -0,0 +1,10 @@ +/** + * @param {number} n + * @return {number} + */ +var hammingWeight = function(n) { + const binary = n.toString(2); + + + return binary.replaceAll('0','').length +}; diff --git a/valid-palindrome/hozzijeong.js b/valid-palindrome/hozzijeong.js new file mode 100644 index 0000000000..7f9d808c6f --- /dev/null +++ b/valid-palindrome/hozzijeong.js @@ -0,0 +1,11 @@ +/** + * @param {string} s + * @return {boolean} + */ +var isPalindrome = function(s) { + const lowercase = s.toLowerCase(); // 소문자로 변환 + const replacedString = lowercase.replaceAll(/[^a-z0-9]/g,''); // 정규표현식을 통해 영어/숫자가 아닌 값들을 ''로 변환 + + + return replacedString === [...replacedString].reverse().join('') // 기존 문자열과 그 값을 뒤집은 문자열이 같은지 비교 +};