Skip to content

Commit d444820

Browse files
authored
Merge pull request DaleStudy#2109 from hozzijeong/main
[hozzijeong] WEEK 03 Solutions
2 parents 7bac230 + 3b96320 commit d444820

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
var hammingWeight = function(n) {
6+
const binary = n.toString(2);
7+
8+
9+
return binary.replaceAll('0','').length
10+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
var isPalindrome = function(s) {
6+
const lowercase = s.toLowerCase(); // μ†Œλ¬Έμžλ‘œ λ³€ν™˜
7+
const replacedString = lowercase.replaceAll(/[^a-z0-9]/g,''); // μ •κ·œν‘œν˜„μ‹μ„ 톡해 μ˜μ–΄/μˆ«μžκ°€ μ•„λ‹Œ 값듀을 ''둜 λ³€ν™˜
8+
9+
10+
return replacedString === [...replacedString].reverse().join('') // κΈ°μ‘΄ λ¬Έμžμ—΄κ³Ό κ·Έ 값을 뒀집은 λ¬Έμžμ—΄μ΄ 같은지 비ꡐ
11+
};

0 commit comments

Comments
Β (0)