You are viewing a single comment's thread. Return to all comments →
Java 15
public static SinglyLinkedListNode reverse(SinglyLinkedListNode llist) { SinglyLinkedListNode prev = null; SinglyLinkedListNode current = llist; SinglyLinkedListNode nextNode = null; while (current != null) { nextNode = current.next; current.next = prev; prev = current; current = nextNode; } return prev; }
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 →
Java 15