You are viewing a single comment's thread. Return to all comments →
Node Reverse(Node head) { if (head == null) { return null; } if (head.next == null) { return head; } Node preNode = null; Node currNode = head; Node nextNode = null; while (currNode != null) { nextNode = currNode.next; currNode.next = preNode; preNode = currNode; currNode = nextNode; } head = preNode; return head; }
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a linked list
You are viewing a single comment's thread. Return to all comments →