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
15 changes: 15 additions & 0 deletions sik9252/MoveZeroes.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,15 @@
var moveZeroes = function (nums) {
let idx = 0;

for (let i = 0; i < nums.length; i++) {
if (nums[i] !== 0) {
nums[idx] = nums[i];
idx++;
}
}

while (idx < nums.length) {
nums[idx] = 0;
idx++;
}
};
19 changes: 19 additions & 0 deletions sik9252/PalindromeLinkedList.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,19 @@
var isPalindrome = function (head) {
const arr = [];

while (head) {
arr.push(head.val);
head = head.next;
}

let left = 0;
let right = arr.length - 1;

while (left < right) {
if (arr[left] !== arr[right]) return false;
left++;
right--;
}

return true;
};
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.

오 left, right라는 변수명이 되게 직관적인 것 같아요.
투포인터를 활용해서도 많이 풀던데 이 방식대로 풀어도 좋을 것 같아요!

Loading