leetcode 237 删除链表中非末尾结点

leetcode 237 删除链表中非末尾结点

# 此做法并非实现结点的真正删除 只是将结点的属性改变
# 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

你可能感兴趣的:(算法及数据结构)