Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sik9252/NumberOf1Bits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var hammingWeight = function (n) {
let count = 0;

while (n !== 0) {
n = n & (n - 1);
count++;
}

return count;
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

크 ... 풀이 간단해서 좋네요 👍

7 changes: 7 additions & 0 deletions sik9252/SameTree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var isSameTree = function (p, q) {
if (!p && !q) return true; // 둘 다 없으면(null)
if (!p || !q) return false; // 둘 중 하나만 없으면(null)
if (p.val !== q.val) return false; // 값이 다르면
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

early return 좋네요!!!


return isSameTree(p.left, q.left) && isSameTree(p.right, q.right); // 서브트리 확인
};
Loading