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: doocs/leetcode
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: omid-web/leetcode
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Feb 10, 2022

  1. Copy the full SHA
    d170c39 View commit details
  2. Update README.md

    yanglbme authored Feb 10, 2022
    Copy the full SHA
    eb2f2cb View commit details
16 changes: 9 additions & 7 deletions solution/0200-0299/0206.Reverse Linked List/README.md
Original file line number Diff line number Diff line change
@@ -37,13 +37,15 @@

class Solution:
def reverseList(self, head: ListNode) -> ListNode:
pre, p = None, head
while p:
q = p.next
p.next = pre
pre = p
p = q
return pre
previous, current, next = None, head, None

while current is not None:
next = current.next
current.next = previous
previous = current
current = next

return previous
```

### **Java**
16 changes: 9 additions & 7 deletions solution/0200-0299/0206.Reverse Linked List/README_EN.md
Original file line number Diff line number Diff line change
@@ -54,13 +54,15 @@

class Solution:
def reverseList(self, head: ListNode) -> ListNode:
pre, p = None, head
while p:
q = p.next
p.next = pre
pre = p
p = q
return pre
previous, current, next = None, head, None

while current is not None:
next = current.next
current.next = previous
previous = current
current = next

return previous
```

### **Java**
16 changes: 9 additions & 7 deletions solution/0200-0299/0206.Reverse Linked List/Solution.py
Original file line number Diff line number Diff line change
@@ -6,10 +6,12 @@

class Solution:
def reverseList(self, head: ListNode) -> ListNode:
pre, p = None, head
while p:
q = p.next
p.next = pre
pre = p
p = q
return pre
previous, current, next = None, head, None

while current is not None:
next = current.next
current.next = previous
previous = current
current = next

return previous