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 - Java Tutorial
From the course: Nail Your Java Interview
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.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Review arrays for technical interviews6m 7s
-
Challenge: Maximum product of two numbers1m 11s
-
Solution: Maximum product of two numbers6m 26s
-
Mastering linked lists for whiteboard coding interviews7m 1s
-
Challenge: Delete the middle of a singly-linked list55s
-
Solution: Delete the middle of a singly-linked list4m 27s
-
-
-
-