Skip to content

[jj7779607] Week7 #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2025
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
23 changes: 23 additions & 0 deletions reverse-linked-list/limlimjo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
var reverseList = function (head) {
let [prev, curr] = [null, head];

while (curr) {
[curr.next, prev, curr] = [prev, curr, curr.next];
}

return prev;
};

// 시간복잡도: O(n)
// 공간복잡도: O(1)
Comment on lines +12 to +23
Copy link
Contributor

@taewanseoul taewanseoul Jan 25, 2025

Choose a reason for hiding this comment

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

이렇게 destructuring assignment를 사용하는 건 생각치 못했네요! 👍

예전에 제가 받은 리뷰인데, 시간복잡도와, 공간복잡도는 코드 위에 적어두면 리뷰하는 분한테 더 보기 편하다고 합니다. 참고해 주세요~

Loading