We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
反转一个单链表。
示例:
输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 进阶: 你可以迭代或递归地反转链表。你能否用两种方法解决这道题?
The text was updated successfully, but these errors were encountered:
/** * Definition for singly-linked list. * function ListNode(val) { * this.val = val; * this.next = null; * } */ /** * @param {ListNode} head * @return {ListNode} */ var reverseList = function(head) { let prev = null; let cur = head; while (cur) { let next = cur.next; cur.next = prev; prev = cur; cur = next; } return prev; };
Sorry, something went wrong.
206. 反转链表 #165
886c8c1
Merge pull request #166 from zzcyes/develop
b980db7
zzcyeah
zzcyes
No branches or pull requests
题目
反转一个单链表。
示例:
The text was updated successfully, but these errors were encountered: