Skip to content

Commit 862dd92

Browse files
committed
Fix reversing double linked list
1 parent f5645bb commit 862dd92

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/data-structures/linked-list.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@
140140
while (current) {
141141
temp = current.next;
142142
current.next = prev;
143+
prev.prev = current;
143144
prev = current;
144145
current = temp;
145146
}
146147
this.first.next = null;
148+
this.last.prev = null;
147149
temp = this.first;
148150
this.first = prev;
149151
this.last = temp;

0 commit comments

Comments
 (0)