top of page
Search

Delete a node in the middle of a singly linked list,given only access to that node.

  • Writer: Abhinaw Tripathi
    Abhinaw Tripathi
  • May 26, 2016
  • 1 min read

Very simple problem but there is only issue with the solution is if the node to be deleted is the last node in the linked list. public static boolean deleteNode(LinkedListNode n) { if(n == null || n.next == null) return false; LinkedListNode next =n.next; n.data =next.data; n.next=next.next; return true; }

 
 
 

Recent Posts

See All

Komentáře


© 2016 by Abhinav Tripathi

  • Facebook Clean Grey
  • Twitter Clean Grey
bottom of page