Skip to content
Merged
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
19 changes: 19 additions & 0 deletions reverse-linked-list/Cyjin-jani.js
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Reverse Linked List
  • 설명: 이 코드는 연결 리스트를 뒤집는 문제로, 반복문을 통해 노드의 포인터를 역순으로 변경하는 패턴입니다. 일반적인 패턴 이름은 없지만, 연결 리스트 뒤집기 특화된 알고리즘입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @param {ListNode} head
* @return {ListNode}
*/
const reverseList = function (head) {
if (!head) return null;

let curr = head;
let prev = null;

while (curr !== null) {
const next = curr.next;
curr.next = prev;
prev = curr;
curr = next;
}

return prev;
};
Loading