Skip to content

Instantly share code, notes, and snippets.

@charlespunk
Created February 12, 2013 15:35
Show Gist options
  • Save charlespunk/4770708 to your computer and use it in GitHub Desktop.
Save charlespunk/4770708 to your computer and use it in GitHub Desktop.
Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node.
public static boolean deleteNode(Node node){
if(node == null || node.next == null) return false; // could not be done when the next node is null
node.data = node.next.date;
node.next = node.next.next;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment