当前位置:网站首页>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;}边栏推荐
- 力扣练习——63 找到字符串中所有字母异位词
- LeetCode 369. Plus One Linked List(链表加1)
- [E-commerce operation] Do you really understand social media marketing (SMM)?
- 嘉为蓝鲸荣获工信部“数字技术融合创新应用解决方案”
- Samsung plans to start producing semiconductor components in Vietnam in 2023
- Licking Exercise - 58 Verifying Binary Search Trees
- Does your child lack self-discipline?Ape Counseling: Pay attention to "blank" in the schedule to give children more control
- 网络套接字(UDP和TCP编程)
- 开源的作者,也有个生活问题
- LeetCode 86. 分隔链表
猜你喜欢

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

StoneDB 文档捉虫活动第一季

制品库是什么?

Do self-media monthly income tens of thousands?Several self-media tools that bloggers are using

Flutter气泡框实现

Nocalhost - 让云原生时代的开发更高效

mpf6_Time Series Data_quandl_更正kernel PCA_AIC_BIC_trend_log_return_seasonal_decompose_sARIMAx_ADFull

std::move()

从源码角度分析UUID的实现原理

OPNsense安装配置Zenarmor
随机推荐
LeetCode 369. Plus One Linked List(链表加1)
LeetCode 19. Delete the Nth last node of the linked list
一文读懂NFT数字藏品为何风靡全球?
Licking Exercise - 58 Verifying Binary Search Trees
LeetCode 138. Copy a linked list with random pointers
jlink and swd interface definition
StoneDB Document Bug Hunting Season 1
Clicking Exercise - 64 Longest Harmonic Subsequences
再有人问你分布式事务,把这篇扔给他
jlink 与 swd 接口定义
Module 9 - Designing an e-commerce seckill system
制品库是什么?
WeChat applet, global variables change in one place and the state in other places also changes.
ViT结构详解(附pytorch代码)
LeetCode 86. 分隔链表
std::move()
从源码角度分析UUID的实现原理
ENVI 5.3软件安装包和安装教程
不止跑路,拯救误操作rm -rf /*的小伙儿
态路小课堂丨如何为CXP光模块选择光纤跳线?