这道题出的也是很巧妙的,一开始我也以为少给了参数,一个不留神看到了java的答案。细细一想果然很有道理。给了很多启发。
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
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
本文详细解析了一道关于链表删除节点的独特题目,通过Java代码实例展示了如何巧妙地仅使用节点信息进行操作,而无需额外的参数。文章提供了定义类节点、初始化节点、以及删除节点的方法实现,旨在为读者提供对链表操作更深入的理解。
996

被折叠的 条评论
为什么被折叠?



