You are viewing a single comment's thread. Return to all comments →
Java 15:
public static SinglyLinkedListNode insertNodeAtPosition(SinglyLinkedListNode llist, int data, int position) { SinglyLinkedListNode node = new SinglyLinkedListNode(data); SinglyLinkedListNode previous = llist; while (position-- > 1) { previous = previous.next; } node.next = previous.next; previous.next = node; return llist; }
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a node at a specific position in a linked list
You are viewing a single comment's thread. Return to all comments →
Java 15: