You are viewing a single comment's thread. Return to all comments →
public static SinglyLinkedListNode deleteNode(SinglyLinkedListNode llist, int position) { if (position == 0) { return llist.next; } SinglyLinkedListNode n = llist; int counter = 0; while(counter <= position) { if(counter == position -1) { if(n.next == null) { return llist; } n.next = n.next.next; return llist; } n = n.next; counter++; } return llist; }
Seems like cookies are disabled on this browser, please enable them to open this website
Delete a Node
You are viewing a single comment's thread. Return to all comments →