Skip to content

Commit 665b526

Browse files
authored
Merge pull request #589 from khuong291/master
Update reverse function in LinkedList
2 parents eb7ec32 + aa900e3 commit 665b526

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Linked List/README.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ How about reversing a list, so that the head becomes the tail and vice versa? Th
451451
```swift
452452
public func reverse() {
453453
var node = head
454+
tail = node // If you had a tail pointer
454455
while let currentNode = node {
455456
node = currentNode.next
456457
swap(&currentNode.next, &currentNode.previous)

0 commit comments

Comments
 (0)