• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 15, 2024 |11.0K Views

Delete middle of linked list

  Share   Like
Description
Discussion

Given a singly linked list, delete the middle of the linked list. For example, if the given linked list is 1->2->3->4->5 then the linked list should be modified to 1->2->4->5

If there are even nodes, then there would be two middle nodes, we need to delete the second middle element. For example, if given linked list is 1->2->3->4->5->6 then it should be modified to 1->2->3->5->6.
If the input linked list is NULL, then it should remain NULL.

If the input linked list has 1 node, then this node should be deleted and a new head should be returned.

Delete middle of linked list: https://www.geeksforgeeks.org/delete-middle-of-linked-list/