当前位置:网站首页>LeetCode 237. Delete a node in a linked list
LeetCode 237. Delete a node in a linked list
2022-08-10 12:00:00 【Mizuna pen】
Original URL: https://leetcode.cn/problems/delete-node-in-a-linked-list/
There is a linked list, delete a given node, and cannot directly access the head node; ensure that the deletion is not the last node;
// node is the node to delete// Since it is guaranteed that it is not the last node to be deleted, you can exchange values with the next node to be deleted, and then delete the latter onepublic void deleteNode(ListNode node) {if(node == null || node.next == null) {return;}ListNode next = node.next;int tmp = node.val;node.val = next.val;next.val = tmp;node.next = next.next;}边栏推荐
猜你喜欢

Nocalhost - Making development more efficient in the cloud-native era

微信小程序,全局变量一个地方改变了其他地方的状态也跟着改变。

常量及数据类型你还记得多少?

Intel pushes 20220809 CPU microcode update to patch Intel-SA-00657 security vulnerability

3款不同类型的自媒体免费工具,有效提高创作、运营效率

基于UiAutomator2+PageObject模式开展APP自动化测试实战

使用哈工大LTP测试分词并且增加自定义字典

dedecms支持Word内容一键导入

three.js模糊玻璃效果

英特尔推送20220809 CPU微码更新 修补Intel-SA-00657安全漏洞
随机推荐
LeetCode 146. LRU 缓存
LeetCode 109. 有序链表转换二叉搜索树
微信小程序,全局变量一个地方改变了其他地方的状态也跟着改变。
【Redis】内存回收策略
Centos7 environment uses Mysql offline installation package to install Mysql5.7
Buckle Exercise - 61 Sort by frequency of characters
HDU 4135: Co-prime (the principle of inclusion and exclusion)
LeetCode 86. Delimited Linked List
Analysis of the implementation principle of UUID from the perspective of source code
搜索--01
HDU 4372:Count the Buildings (Stirling数)
VSCode远程连接服务器报错:Could not establish connection to “xxxxxx”的可能错误原因及解决
AutoCAD Map 3D功能之一暴力处理悬挂点(延伸)
LeetCode 19. Delete the Nth last node of the linked list
CLIP还能做分割任务?哥廷根大学提出一个使用文本和图像prompt,能同时作三个分割任务的模型CLIPSeg,榨干CLIP能力...
网络基础(第一节)
LeetCode 138. 复制带随机指针的链表
APP automation testing practice based on UiAutomator2+PageObject mode
即时零售业态下如何实现自动做账?
Apple bucks the trend and expands iPhone 14 series stocking, with a total of 95 million units