by Rockdtben · 13y ago · 0 comments
http://jsbin.com/ugojoq/267/edit
LinkedList.prototype.reverse = function () {
var start = this.head;
var prev = this.head;
var curr = prev.next;
prev.next = null;
while(curr !== null) {
var next = curr.next;
curr.next = prev;
prev = curr;
curr = next;
}
this.head = prev;
};No comments yet.