当前位置:网站首页>剑指 Offer 18. 删除链表的节点
剑指 Offer 18. 删除链表的节点
2022-07-16 03:22:00 【愈努力俞幸运】
剑指 Offer 18. 删除链表的节点
https://leetcode.cn/problems/shan-chu-lian-biao-de-jie-dian-lcof/
思路一模一样,注释代码会超时,啊这。。。。
'''
#超时
class Solution:
def deleteNode(self, head, v):
if head.val==v:
return head.next
else:
pre=head
cur=head.next
while cur:
if cur.val==v:
pre.next=cur.next
else:
#pre=cur
#cur=cur.next
pre,cur=cur,cur.next
return head
'''
class Solution:
def deleteNode(self, head, v):
if head.val==v:
return head.next
else:
pre=head
cur=head.next
while cur and cur.val!=v:
pre,cur=cur,cur.next
if cur:pre.next=cur.next
return head边栏推荐
- A survey on dialogue systems: recent advances and new frontiers
- 打工人打工魂!销售分析案例来啦!
- IIC读写EEPROM
- hcip第六天笔记
- JS small effect jump according to the corresponding item name
- Mysql5.7创建用户错误:ERROR 1364 (HY000): Field ‘ssl_cipher‘ doesn‘t have a default value解决方法
- 【机器学习】决策树 – Decision Tree
- 端口轉發工具 rinetd
- Today's job insights
- Rust iter& match
猜你喜欢
随机推荐
变焦跟踪理论基础
Analysis of Wireshark Ethernet frame
Jincang database kingbasees SQL language reference manual (3.1.1.12. XML type)
Outil de transfert de port rinetd
批流融合升级:Apache Flink 1.15.0 发布 Pulsar Flink Sink Connector
Google Earth engine app (GEE) - load a searchable Spector
JS small effect jump according to the corresponding item name
Word -- set tab width
(笔记)ideavim和ide冲突解决方法
The share price fell through! Is Muse going to pay for the "IQ tax"?
Implementation of MCU stack backtracking debugging principle based on gd32 c10x
示波器的带宽介绍
A survey on dialogue systems: recent advances and new frontiers
Source insight 4 what about Chinese garbled code?
第十九周作业
内存管理页面属性
ReversingKr-wp(7)
EFCore——Entry和Attach
模板_欧氏筛_素数
金仓数据库 KingbaseES SQL 语言参考手册 (3.1.1.10. 文本搜索类型、3.1.1.11. UUID类型)









