You are viewing a single comment's thread. Return to all comments →
Easiest Solution
public static SinglyLinkedListNode deleteNode(SinglyLinkedListNode head, int index) { SinglyLinkedListNode temp = head;
if(index == 0){ head = head.next; }else { for(int i = 0; i < index - 1; i++){ temp = temp.next; } temp.next = temp.next.next; } return head; }
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 →
Easiest Solution
public static SinglyLinkedListNode deleteNode(SinglyLinkedListNode head, int index) { SinglyLinkedListNode temp = head;