I noticed that a second implementation of the function of interest was missing from this post. I have updated the GitHub repo and the post. Sorry about that!
In this post we will solve the LeetCode 237 Delete Node in a Linked List problem using the Java programming language and the VSCode IDE on a Windows platform. Java is quite portable so it should run on most (never generalize) platforms.
Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. Constraints: o The number of the nodes in the given list is in the range [2, 1000]. o -1000 &lt;= Node.val &lt;= 1000 o The value of each node in the list is unique. o The node to be deleted is in the list and is not a tail node
The problem at first glance seems to be simple. We have to delete a node from a singly linked list. The complication arises when we are only given the node to delete. In general, to delete a node from a linked list we are given the head of the linked list. Continue reading “LeetCode 237. Delete Node in a Linked List in Java”