From the course: Nail Your Java Interview

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Delete the middle of a singly-linked list

Challenge: Delete the middle of a singly-linked list - Java Tutorial

From the course: Nail Your Java Interview

Start my 1-month free trial

Challenge: Delete the middle of a singly-linked list

(upbeat music) - [Narrator] It's time to test your knowledge of linked lists in this Java interview question. Your challenge is given a singly-linked list, delete the middle node from the list. Your function should modify the original list and not return a new list. Your list may have an even number of elements or an odd number of elements. In the case of an even size, you should delete the element on the farther side. Also, make no assumptions about your data. The list could have any type of data in it. For this interview question you'll need access to the next pointers in your list. So I recommend you implement the linked list data structure using a custom class that has a data attribute and a reference to the next node. Good luck.

Contents