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
27 changes: 27 additions & 0 deletions sik9252/BackspaceStringCompare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var backspaceCompare = function (s, t) {
const calcS = calc(s);
const calcT = calc(t);

return calcS === calcT;
};

var calc = function (str) {
const stack = [];

for (let i = 0; i < str.length; i++) {
if (!stack.length && str[i] === "#") continue;

if (str[i] === "#") {
stack.pop();
} else {
stack.push(str[i]);
}
}

return [...stack].join("");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

stack이 배열인데 다시 배열에 넣어주고 있는 것 같아 보여요!

};
17 changes: 17 additions & 0 deletions sik9252/CountingBits.js
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

비트연산 지식이 장착되어 있으시다니 멋져요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var countBits = function (n) {
const result = [];

for (let i = 0; i <= n; i++) {
let num = i;
let count = 0;

while (num > 0) {
num = num & (num - 1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

여기 부분이 어떻게 동작하는지 설명 부탁드려도 될까요?!

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.

오 이렇게 푸는방법도 있네요!!!


result.push(count);
}

return result;
};
Loading