In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to delete nodes in Linked List. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
Delete Node in a Linked List
Title
Please write a function so that it can delete the given (not the end) node in a linked list, and you will only be given the node that is required to be deleted.
There is a linked list-- head = [4, 5, 5, 1, 9], which can be expressed as:
4-> 5-> 1-> 9
Example 1:
Input: head = [4, 5, 1, 10, 9], node = 5
Output: [4Jing 1JI 9]
Explanation: given the second node in your linked list with a value of 5, after calling your function, the linked list should become 4-> 1-> 9.
Example 2:
Input: head = [4pm 5pm 1je 9], node = 1
Output: [4, 5, 5, 9]
Explanation: given the third node in your linked list with a value of 1, after calling your function, the linked list should become 4-> 5-> 9.
Description:
The linked list contains at least two nodes.
The values of all nodes in the linked list are unique.
The given node is a non-trailing node and must be a valid node in the linked list.
Do not return any results from your function.
Problem-solving ideas
The point to note in this question is that it does not give us a starting point for the linked list, only a node to be deleted, which is slightly different from what we have dealt with in the past.
The solution to this problem is to overwrite the value of the current node with the value of the next node, and then we can delete the next node.
Animation demonstration
The animation GIF is a little big. Please wait a little while to load and display ^ _ ^.
After reading the above in the reference code, do you have any further understanding of how to delete nodes in Linked List? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 237
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.