Skip to content

Commit

Permalink
fix: refactor list
Browse files Browse the repository at this point in the history
  • Loading branch information
obzva committed Oct 26, 2024
1 parent 74f4456 commit 5000053
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions reorder-list/flynn.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@
curr = tmp
}
// merge two parts of the list
curr1, curr2 := head, prev
for curr2.Next != nil {
tmp := curr1.Next
curr1.Next = curr2
curr1 = tmp
tmp = curr2.Next
curr2.Next = curr1
curr2 = tmp
for curr1, curr2 := head, prev; curr2.Next != nil; {
tmp1, tmp2 := curr1.Next, curr2.Next
curr1.Next, curr2.Next = curr2, curr1.Next
curr1, curr2 = tmp1, tmp2
}
}

0 comments on commit 5000053

Please sign in to comment.