Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: azl397985856/leetcode
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: water2bear/leetcode
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

There isn’t anything to compare.

azl397985856:master and water2bear:master are entirely different commit histories.

Showing with 9 additions and 9 deletions.
  1. +9 −9 problems/206.reverse-linked-list.md
18 changes: 9 additions & 9 deletions problems/206.reverse-linked-list.md
Original file line number Diff line number Diff line change
@@ -66,18 +66,18 @@ A linked list can be reversed either iteratively or recursively. Could you imple
* @return {ListNode}
*/
var reverseList = function(head) {
const dummyHead = {
next: head
}
let current = dummyHead.next;
if (!head || !head.next) return head;

let cur = head;
let pre = null;

while(current) {
const next = current.next;
current.next = pre;
pre = current;
current = next;
while(cur) {
const next = cur.next;
cur.next = pre;
pre = cur;
cur = next;
}

return pre;
};