Skip to content

Instantly share code, notes, and snippets.

Created May 3, 2018 17:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Linked List Remove Node
public class LinkedList<T> {
// Reference to the head node
Node head;
public void removeNode(T data){
// check if list empty
if(head == null) return;
// check head's data if equal
// and assign next node as head
if( == data){
head =;
// get head reference
Node current = head;
// iterate list
while( != null){
// check next node's data
// skip next node
if( == data){ =;
// go to next node
current =;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment