题目要求

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.

题目分析及思路

要求写一个函数,删除一个单链表中的一个结点(除了最后一个)。函数不需要返回值,只需要原地修改给定删除结点。我们可以将要删除结点的两个属性用该结点的下一个结点的两个属性来替代。

python代码

# Definition for singly-linked list.

# class ListNode:

#     def __init__(self, x):

#         self.val = x

#         self.next = None

class Solution:

def deleteNode(self, node):

"""

:type node: ListNode

:rtype: void Do not return anything, modify node in-place instead.

"""

node.val = node.next.val

node.next = node.next.next

LeetCode 237 Delete Node in a Linked List 解题报告的更多相关文章

  1. [LeetCode] 237. Delete Node in a Linked List 解题思路

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  2. 【LeetCode】237. Delete Node in a Linked List 解题报告 (Java&Python&C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 设置当前节点的值为下一个 日期 [LeetCode] ...

  3. LeetCode 237. Delete Node in a Linked List (在链表中删除一个点)

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  4. [LeetCode] 237. Delete Node in a Linked List 删除链表的节点

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  5. (easy)LeetCode 237.Delete Node in a Linked List

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  6. leetcode 237 Delete Node in a Linked List python

    题目: Write a function to delete a node (except the tail) in a singly linked list, given only access t ...

  7. 17.leetcode 237. Delete Node in a Linked List

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  8. [Leetcode]237. Delete Node in a Linked List -David_Lin

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  9. LeetCode 237. Delete Node in a Linked List 删除链表结点(只给定要删除的结点) C++/Java

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

随机推荐

  1. MySQL技术内幕读书笔记(二)——InnoDB存储引擎

    目录 InnoDB存储引擎 InnoDB存储架构 Checkpoint技术 Master Thread 工作方式 InnoDB关键特性(放一下,感觉看后面,再看总结吧) InnoDB存储引擎 Inno ...

  2. Android Glide 源码分析系列(待完成)

    参考:https://jekton.github.io/2018/06/08/glide-disk-cache/ 参考:https://jekton.github.io/2018/06/20/glid ...

  3. Why does deep learning work?

    Learning Deep Architectures for AI By Yoshua Bengio http://www.iro.umontreal.ca/~bengioy/papers/ftml ...

  4. 【Shiro】小读Shiro Filter

    类继承结构图 看不明白此图不要紧,后面慢慢提到此图的类: AbstractFilter,抽象过滤器 它实现Filter.继承ServletContextSupport. 它主要实现了init(Filt ...

  5. nginx:not a directory

    项目需要在nginx中提供一个配置文件返回接口的信息,于是就添加了location来实现,本以为很简单的操作,结果访问配置文件时一直返回404,nginx的error log中输出:not a dir ...

  6. CentOS 7下PXE+Kickstart无人值守安装操作系统

    1.简介 1.1. 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支 ...

  7. mybatis查询结果和接收的不一样

    记一次大坑:mybatis查询结果和接收的不一样,折腾我好几个小时. 先上代码:代码是要查询排名,sql执行的结果 SELECT b.operator_id, b.class_count, b.cla ...

  8. HttpWebRequest 基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系

    请求对象前加入 ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; 然后实现该方法 ...

  9. ASP.NET Web Forms - 网站导航(Sitemap 文件)

    [参考]ASP.NET Web Forms - 导航 ASP.NET 带有内建的导航控件. 网站导航 维护大型网站的菜单是困难而且费时的. 在 ASP.NET 中,菜单可存储在文件中,这样易于维护.文 ...

  10. c#判断是否有网络

    //调用操作系统API [System.Runtime.InteropServices.DllImport("wininet")] private extern static bo ...